Grafana Loki Integration

Connect Grafana Loki to query your application logs with LogQL from inside TestRelic and line them up with failing tests.

The Grafana Loki integration lets you query application log data from your Loki stack inside TestRelic, so you can correlate test failures with the server-side log output that occurred while the test ran.

API test session
Loki logs
TestRelic workspace

What this integration enables

  • LogQL explorer — Query your Loki logs from inside TestRelic, in the Grafana Loki console, without switching tools.
  • Test and service shortcuts — One-click queries for the logs of a specific test id or service, so you can line up a failing test with the server-side log output around it.
  • Errors only — Narrow any query to error lines.

Workspace logs come from TestRelic

The log views inside the Session and API Test Workspaces (see the Cloud Platform section) show the logs TestRelic captured with the run. Loki logs are queried from the Loki console.

Connecting Grafana Loki

  1. Navigate to Settings → Integrations and open the Marketplace tab.
  2. Click Connect on the Grafana Loki card.
  3. Provide:
    • Loki URL — The base URL of your Loki HTTP API (e.g. https://loki.yourcompany.com), not a /loki/api/v1 path — TestRelic appends the query path itself
    • Org ID — The tenant ID for multi-tenant Loki, sent as the X-Scope-OrgID header. Single-tenant deployments can leave it at 1
    • Username and Password / API Key — Basic-auth credentials for your Loki endpoint
  4. Click Test Connection, then Connect.

Loki console

Settings → Integrations → Grafana Loki → Open console lets you run any LogQL query over a Time range, with shortcuts for Errors only, By service and By test id.

Grafana Cloud Loki

If you use Grafana Cloud, take the Loki data source URL from your stack details page (it looks like https://logs-prod-XXXXX.grafana.net). Use your Grafana Cloud stack username and API key (not your Grafana account credentials) for authentication.

Reading results

The console shows matching log lines in a dense table, with the timestamp on the left and the Loki stream labels available on each line. If nothing matches, it reads "No log lines in this window" — widen the Time range or relax the query.

How logs are queried

TestRelic queries Loki using LogQL over the time window you are looking at. The query runs from TestRelic's servers — your Loki credentials are never sent to the browser.

Example LogQL query:

Example LogQL query
{app="backend", env="staging"} | logfmt | level != "debug"
Was this page helpful?

On this page