---
title: Telegraf Documentation
description: Telegraf plugin for sending metrics to Grafana Loki
url: https://docs.influxdata.com/telegraf/v1/output-plugins/loki/
estimated_tokens: 1344
product: Telegraf
version: v1
---

-   Telegraf v1.18.0+

# Grafana Loki Output Plugin

This plugin writes logs to a [Grafana Loki](https://grafana.com/loki) instance, using the metric name and tags as labels. The log line will contain all fields in `key="value"` format easily parsable with the `logfmt` parser in Loki.

Logs within each stream are sorted by timestamp before being sent to Loki.

**Introduced in:** Telegraf v1.18.0 **Tags:** logging **OS support:** all

## Global configuration options

Plugins support additional global and plugin configuration settings for tasks such as modifying metrics, tags, and fields, creating aliases, and configuring plugin ordering. See [CONFIGURATION.md](/telegraf/v1/configuration/#plugins) for more details.

## Secret-store support

This plugin supports secrets from secret-stores for the `username` and `password` option. See the [secret-store documentation](/telegraf/v1/configuration/#secret-store-secrets) for more details on how to use them.

## Configuration

```toml
# A plugin that can transmit logs to Loki
[[outputs.loki]]
  ## The domain of Loki
  domain = "https://loki.domain.tld"

  ## Endpoint to write api
  # endpoint = "/loki/api/v1/push"

  ## Connection timeout, defaults to "5s" if not set.
  # timeout = "5s"

  ## Basic auth credential
  # username = "loki"
  # password = "pass"

  ## Additional HTTP headers
  # http_headers = {"X-Scope-OrgID" = "1"}

  ## If the request must be gzip encoded
  # gzip_request = false

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## Sanitize Tag Names
  ## If true, all tag names will have invalid characters replaced with
  ## underscores that do not match the regex: ^[a-zA-Z_]()*.
  # sanitize_label_names = false

  ## Metric Name Label
  ## Label to use for the metric name to when sending metrics. If set to an
  ## empty string, this will not add the label. This is NOT suggested as there
  ## is no way to differentiate between multiple metrics.
  # metric_name_label = "__name"
```

#### Related

-   [Configure plugins](/telegraf/v1/configure_plugins/)
-   [Grafana Loki Plugin Source](https://github.com/influxdata/telegraf/tree/v1.38.4/plugins/outputs/loki/README.md)
