Skip to content

Vector: Write log data with Loki API

Last updated on

Vector is another popular observability tool which can collect logs and ship them to multiple destinations. It has built-in support available for Loki as a sink which can be configured to target STACKIT Logs instance using Loki API.

Vector sink for Logs can be configured with the next steps. The vector.yaml output of steps is shown first, you can extend it according to your requirements.

vector.yaml
sinks:
stackit_logs_sink: # sink id
type: loki
# NOTE: client internally will append /loki/api/v1/push
endpoint: <put-url-of-data-source-in-logs-instance>
auth:
strategy: bearer # bearer strategy will put the token as bearer authorization header
token: <Token value from Logs instance Access Token>
healthcheck:
enabled: false
encoding:
codec: json
labels:
test_label: test_value
# ...
  1. Create or edit the vector configuration file usually named vector.yaml
  2. Add a new sink object under sinks with type: loki so that it uses Loki format.
  3. In the sink set the endpoint key with value of STACKIT Logs instance’s data source URL.
  4. In the sink set auth.strategy value bearer
  5. Set the auth.token key with value of the access token for STACKIT Logs instance. Make sure the token has write permissions.
  6. Disable healthcheck for Loki by setting healthcheck.enabled to false
  7. Set json encoding for sending data with encoding.codec: json
  8. Set appropriate labels under labels which are attached before sending data
  9. You can now further configure the output according to your needs. See the configuration of the sink for more details.