Vector is a great way to send logs into Hydrolix!
As Vector supports HTTP output and formatting the data in JSON it’s very easy to setup and index everything in Hydrolix.
In this example we’ll instal vector on an Ubuntu server, get the logs from journald and index using streaming to Hydrolix.
Install vector on Ubuntu
Following the installation guide you can use the apt package available:
1 2 | curl –1sLf ‘https://repositories.timber.io/public/vector/cfg/setup/bash.deb.sh’ | sudo –E bash sudo apt–get install vector |
Vector will be installed and launch as a service on your server, we’ll modify the configuration to send the data to Hydrolix.
Setting Hydrolix table and transform for journald
Hydrolix requires the table and the schema to index your journald logs, you can use the following example to create the project and table.
To use this example you can refer to this article on how to setup VSCode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | ### Global variable to replace with your own needs @host = $customer @projectname = sample @tablename = journald @transformname = journald_transform @username = “YYYYYYY” @password = “XXXXXXXX” #### DO NOT MODIFY BELOW #### @base_url = https://{{host}}.hydrolix.live/config/v1/ @post_endpoint = https://{{host}}.hydrolix.live/ingest/event @sql_endpoint = https://{{host}}.hydrolix.live/query/ ### Login authentication get access token and UUID Org variable # @name login POST {{base_url}}login Content–Type: application/json { “username”: {{username}}, “password”: {{password}} } ### Store, parse the login response body to store the access token and organization id @access_token = {{login.response.body.auth_token.access_token}} @org_id = {{login.response.body.orgs[0].uuid}} ### Create a new project using the variable {{projectname}} # @name new_project POST {{base_url}}orgs/{{org_id}}/projects/ Authorization: Bearer {{access_token}} Content–Type: application/json { “name”: “{{projectname}}”, “org”: “{{org_id}}” } ### Store, parse project ID from response @projectid = {{new_project.response.body.uuid}} ### Create a new table named {{tablename}} in the {{projectname}} # @name new_table POST {{base_url}}orgs/{{org_id}}/projects/{{projectid}}/tables/ Authorization: Bearer {{access_token}} Content–Type: application/json { “name”: “{{tablename}}”, “project”: “{{projectid}}”, “description”: “Journald Logs from Vector”, “settings”: { “merge”: { “enabled”: true } } } ### Store, parse table ID from response @tableid = {{new_table.response.body.uuid}} #### Creates a a transform for the json format and upload to our table # @name new_transform POST {{base_url}}orgs/{{org_id}}/projects/{{projectid}}/tables/{{tableid}}/transforms/ Authorization: Bearer {{access_token}} Content–Type: application/json { “name”: “{{transformname}}”, “description”: “Transform JournalD logs from Vector”, “table”: “{{tableid}}”, “type”: “json”, “settings”: { “is_default”: true, “compression”: “none”, “format_details”: { “flattening”: { “active”: false } }, “output_columns”: [ { “name”: “PRIORITY”, “datatype”: { “type”: “uint8”, “index”: true } }, { “name”: “SYSLOG_FACILITY”, “datatype”: { “type”: “uint8”, “index”: true } }, { “name”: “SYSLOG_IDENTIFIER”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “SYSLOG_TIMESTAMP”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_AUDIT_LOGINUID”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “_AUDIT_SESSION”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “_BOOT_ID”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_CAP_EFFECTIVE”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_CMDLINE”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_COMM”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_EXE”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_GID”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “_MACHINE_ID”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_PID”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “_SELINUX_CONTEXT”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_SOURCE_REALTIME_TIMESTAMP”, “datatype”: { “type”: “epoch”, “index”: true, “format”: “us”, “resolution”: “ms” } }, { “name”: “_SYSTEMD_CGROUP”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_SYSTEMD_INVOCATION_ID”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_SYSTEMD_OWNER_UID”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “_SYSTEMD_SESSION”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “_SYSTEMD_SLICE”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_SYSTEMD_UNIT”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_SYSTEMD_USER_SLICE”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_TRANSPORT”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “_UID”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “__MONOTONIC_TIMESTAMP”, “datatype”: { “type”: “uint64”, “index”: true } }, { “name”: “__REALTIME_TIMESTAMP”, “datatype”: { “type”: “epoch”, “index”: true, “format”: “us”, “resolution”: “ms” } }, { “name”: “host”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “message”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “source_type”, “datatype”: { “type”: “string”, “index”: true } }, { “name”: “timestamp”, “datatype”: { “type”: “datetime”, “format”: “2006-01-02T15:04:05.999999Z”, “resolution”: “ms”, “primary”: true } } ] } } |
Configuring Vector
After settings up your Hydrolix configuration and table you can setup Vector to start sending logs !
You can use your favourite text editor to edit /etc/vector/vector.toml
This is what the configuration looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 | [sources.journal_source] type = “journald” [sinks.hydrolix] type = “http” inputs = [“journal_source”] uri = “https://$host.hydrolix.live/ingest/event” encoding = “json” compression = “gzip” [sinks.hydrolix.headers] X–HDX–Table = “$project.$table” X–HDX–Transform = “$transform” |
Obviously you need to replace your hostname, your project, table and transform name.
Those are specify in the example above.