Logstash
Logstash collects, transforms, and ships events. Its http output plugin can send them to the Hydrolix HTTP Stream API. The examples on this page use Elastic Common Schema (ECS) fields, and the same steps work for any JSON events.
Prerequisites⚓︎
- Logstash with the
httpoutput plugin. To install Logstash, see Installing Logstash. To check for the plugin, runbin/logstash-plugin list. - A Hydrolix project and table. To create a table, see Create a table using the API.
- A token for the HTTP Stream API. A long-running pipeline should use a service account token. To create one, see Manage Service Accounts: Service account tokens.
Create a transform for ECS data⚓︎
Logstash sends ECS fields as nested JSON objects, such as {"log": {"level": "info"}}. A transform reads a nested field with from_json_pointers and a JSON Pointer path, such as /log/level.
This transform maps the ECS fields most events carry. is_default: true makes it the table's default transform. To publish it to the table, see Publish a Transform.
To store more fields, add an output column for each. Find field names and types in the ECS field reference.
Configure the Logstash http output⚓︎
Add an http output to the pipeline. Replace my_project.ecs_logs and ecs_json with the table and transform names.
| Logstash Pipeline Output | |
|---|---|
format => "json_batch"sends each batch of events as one JSON array in one request.${HDX_HOSTNAME}and${HDX_TOKEN}come from environment variables or the Logstash keystore. Keep the token in the keystore, not in the pipeline file.
For every setting, see the http output plugin reference.
Logstash drops batches that Hydrolix rejects
By default, the http output retries only 429, 500, 502, 503, and 504 responses. A batch rejected with any other status, such as 401 for a bad token, is dropped. Logstash logs Encountered non-2xx HTTP code, with the status and the response body.
Verify⚓︎
Query the table after a minute or two. Right after the table or transform is created, requests can fail with 400 no table ‘x’ found or unknown transform ‘x’ for a short time. For causes and fixes, see Ingest returns HTTP 400.
| Count Recent ECS Events | |
|---|---|
Send Beats data⚓︎
Beats agents, such as Filebeat, can reach Hydrolix two ways:
- Through Logstash: send Beats output to the Logstash
beatsinput, then use thehttpoutput on this page. To configure Filebeat, see Configure the Logstash output. - Through Kafka: send Beats output to a Kafka topic, and ingest the topic with a Hydrolix Kafka source. To set up the source, see Kafka.
Troubleshoot⚓︎
Something not working?
Start at Troubleshooting Symptoms and Fixes. Find the symptom, confirm it with the signal listed there, and follow the link to the procedure.
Requests fail with an HTTP error⚓︎
Required access: User
Confirm: The status code and response body name the problem: 401: Unauthorized (the Authorization header), 403 with missing or bad auth token (a table access token), 400 with a message such as no table ‘x’ found or unhandled content-type ‘x’ (the table, transform, or format), or 404 with not found (the path). No response at all, such as a timeout, means the sender can't reach the cluster.
The status code shows which part of the request was refused.
Fix: correct the part the status code points to.
- 401: the
Authorizationheader is missing, malformed, or not valid, such as an expired token. Get a new token. An integration that runs unattended should use a service account token. See Manage Service Accounts: Service account tokens. - 403: the table requires a table access token, in addition to the
Authorizationheader. Send one from its token list in theX-Hdx-Tokenheader or thetokenquery string parameter. See Table Access Tokens. - 400: the response body names the problem. See Ingest returns HTTP 400.
- 404: send requests to
https://hostname.hydrolix.live/ingest/event. - No response: check the hostname, and that the sender can reach the cluster over HTTPS.