Skip to content

Loki Direct

loki

The Loki Direct adapter allows you to query Loki installations directly, without routing through Grafana. Use this adapter if you have a standalone Loki deployment or want to bypass Grafana.

FeatureLoki DirectGrafana Browser
ConnectionDirect HTTP to LokiThrough Grafana UI
AuthenticationURL-based (API key in URL or basic auth)Browser-based (Grafana login)
Best forStandalone Loki or scripted accessGrafana-hosted Loki
Setup complexitySimpleMay require proxy/auth
url string

The base URL of your Loki instance (e.g., http://loki.example.com:3100 or http://localhost:3100).

listenPort number Optional

The port to use for connections. Default matches the port in the url parameter.

filter array Optional

A list of filter objects to apply to your queries. Each filter object should have:


  • key (string): The label or field to filter on.
  • value (string): The value to match.
  • operator (enum): One of =, =~, !=, !~ (exact match, regex match, not equal, not regex match).
querySuffix array Optional

Additional query suffixes to append to your Loki queries.

connectors:
- type: loki
name: loki_direct
params:
url: "http://loki.example.com:3100"
connectors:
- type: loki
name: loki_prod
params:
url: "http://loki.example.com"
listenPort: 3100
connectors:
- type: loki
name: loki_filtered
params:
url: "http://loki.example.com:3100"
filter:
- key: "environment"
value: "production"
operator: "="
- key: "service"
value: "api"
operator: "="
querySuffix: ["| json"]
  • The url parameter is required. It should point to your Loki instance’s root URL.
  • You may need to include authentication details in the URL itself (e.g., http://user:password@loki.example.com:3100) or configure authentication separately depending on your Loki setup.
  • The filter parameter works the same as in the Grafana Loki Browser adapter — it restricts logs at the adapter level before processing.
  • Use querySuffix to append operations like | json to automatically parse JSON logs.

Connection refused: Verify the url is correct and the Loki instance is running and accessible.

401 Unauthorized: If your Loki instance requires authentication, ensure credentials are included in the URL or are configured at the network level.

No results: Check that your filters match existing labels in your Loki instance.


For more information on Loki query syntax and labels, see the Grafana Loki documentation.