Loki Direct
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.
Differences from Grafana Loki Browser
Section titled “Differences from Grafana Loki Browser”| Feature | Loki Direct | Grafana Browser |
|---|---|---|
| Connection | Direct HTTP to Loki | Through Grafana UI |
| Authentication | URL-based (API key in URL or basic auth) | Browser-based (Grafana login) |
| Best for | Standalone Loki or scripted access | Grafana-hosted Loki |
| Setup complexity | Simple | May require proxy/auth |
Params
Section titled “Params”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.
Examples
Section titled “Examples”Minimal Configuration
Section titled “Minimal Configuration”connectors: - type: loki name: loki_direct params: url: "http://loki.example.com:3100"With Port Specification
Section titled “With Port Specification”connectors: - type: loki name: loki_prod params: url: "http://loki.example.com" listenPort: 3100With Filters and Query Suffix
Section titled “With Filters and Query Suffix”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"]Usage Notes
Section titled “Usage Notes”- The
urlparameter 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
filterparameter works the same as in the Grafana Loki Browser adapter — it restricts logs at the adapter level before processing. - Use
querySuffixto append operations like| jsonto automatically parse JSON logs.
Troubleshooting
Section titled “Troubleshooting”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.
Related Adapters
Section titled “Related Adapters”For more information on Loki query syntax and labels, see the Grafana Loki documentation.