Vector: Write log data with Loki API
Zuletzt aktualisiert am
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.
Prerequisites
Section titled “Prerequisites”- You have a STACKIT Logs Instance: Create your first STACKIT Logs instance
- You have credentials with write permission for the STACKIT Logs Instance: Retrieve credentials for STACKIT Logs instance
- Data source URL of the STACKI Logs Instance: Retrieve API URL STACKIT Logs instance
Client Configuration
Section titled “Client Configuration”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.
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 # ...- Create or edit the vector configuration file usually named
vector.yaml - Add a new sink object under
sinkswithtype: lokiso that it uses Loki format. - In the sink set the
endpointkey with value of STACKIT Logs instance’s data source URL. - In the sink set
auth.strategyvaluebearer - Set the
auth.tokenkey with value of the access token for STACKIT Logs instance. Make sure the token has write permissions. - Disable healthcheck for Loki by setting
healthcheck.enabledtofalse - Set json encoding for sending data with
encoding.codec: json - Set appropriate labels under
labelswhich are attached before sending data - You can now further configure the output according to your needs. See the configuration of the sink for more details.