> ## Documentation Index
> Fetch the complete documentation index at: https://flipt-oci-manifest-version.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Observability

> This document describes how to configure Flipt's observability mechanisms including metrics, logging, and tracing.

## Metrics

Flipt exposes [Prometheus](https://prometheus.io/) metrics at the `/metrics`
HTTP endpoint. To see which metrics are currently supported, point your browser
to `FLIPT_HOST/metrics` (ex: `localhost:8080/metrics`).

You should see a bunch of metrics being recorded such as:

```yaml
flipt_cache_hit_total{cache="memory",type="flag"} 1
flipt_cache_miss_total{cache="memory",type="flag"} 1
---
go_gc_duration_seconds{quantile="0"} 8.641e-06
go_gc_duration_seconds{quantile="0.25"} 2.499e-05
go_gc_duration_seconds{quantile="0.5"} 3.5359e-05
go_gc_duration_seconds{quantile="0.75"} 6.6594e-05
go_gc_duration_seconds{quantile="1"} 0.00026651 go_gc_duration_seconds_sum
0.000402094 go_gc_duration_seconds_count 5
```

An [example](https://github.com/flipt-io/flipt/tree/main/examples/metrics)
showing how to set up Flipt with Prometheus can be found in the GitHub repository.

### Dashboards

![Grafana Dashboard](https://mintlify.s3-us-west-1.amazonaws.com/flipt-oci-manifest-version/images/configuration/grafana_flag_dashboard.png)

We provide a set of [Grafana](https://grafana.com/) dashboards that you can use to visualize the metrics collected by Flipt, including both server health and flag evaluation metrics.

You can find the dashboards in our [grafana-dashboards](https://github.com/flipt-io/grafana-dashboards) repository.

## Logging

Flipt writes logs to STDOUT in two formats:

* JSON
* Console

The format can be configured via the `log.encoding` configuration option.

```yaml
log:
  encoding: json
```

For production deployments, we recommend using the JSON format as it's easier to parse and ingest into log aggregation systems such as Elasticsearch, Splunk, Loki, or DataDog.

We've prepared an [example](https://github.com/flipt-io/flipt/tree/main/examples/audit/log) showing how to set up Flipt with Grafana Loki and Promtail to ingest and query logs.

### JSON

```json
{
  "L": "INFO",
  "T": "2024-01-20T21:59:49-05:00",
  "M": "finished unary call with code OK",
  "server": "grpc",
  "grpc.start_time": "2024-01-20T21:59:49-05:00",
  "system": "grpc",
  "span.kind": "server",
  "grpc.service": "flipt.evaluation.EvaluationService",
  "grpc.method": "Boolean",
  "peer.address": "127.0.0.1:52635",
  "grpc.code": "OK",
  "grpc.time_ms": 0.146
}
```

### Console

```text
2024-01-20T22:04:18-05:00	INFO	finished unary call with code OK	{"server": "grpc", "grpc.start_time": "2024-01-20T22:04:18-05:00", "system": "grpc", "span.kind": "server", "grpc.service": "flipt.evaluation.EvaluationService", "grpc.method": "Boolean", "peer.address": "127.0.0.1:53714", "grpc.code": "OK", "grpc.time_ms": 0.373}
```

More information about the available configuration options can be found in the [Logging configuration](/configuration/overview#logging) section.

## Tracing

Flipt supports distributed tracing via the [OpenTelemetry](https://opentelemetry.io/) project.

Currently, we support the following tracing backends:

* [Jaeger](https://www.jaegertracing.io/)
* [Zipkin](https://zipkin.io/)
* [OTLP](https://opentelemetry.io/docs/reference/specification/protocol/)

Enable tracing via the values described in the [Tracing configuration](/configuration/overview#tracing) and point Flipt to your configured collector to record spans.

[Examples](https://github.com/flipt-io/flipt/tree/main/examples/tracing) showing how to set up Flipt with each of the supported tracing backends can be found in the main GitHub repository .

### OTLP

![DataDog OTLP](https://mintlify.s3-us-west-1.amazonaws.com/flipt-oci-manifest-version/images/configuration/datadog_otlp.png)

OTLP supports additional configuration such as specifying the protocol to use (gRPC or HTTP) as well as providing custom headers to send with the request.

Custom headers can be used to provide authentication information to the collector which may be required if you are using a hosted collector such as [NewRelic](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/get-started/opentelemetry-set-up-your-app/), [DataDog](https://docs.datadoghq.com/opentelemetry/otlp_ingest_in_the_agent/?tab=host), or [Honeycomb](https://docs.honeycomb.io/getting-data-in/opentelemetry-overview/#instrumenting-with-opentelemetry).

These can be configured via the `tracing.otlp` configuration section.

```yaml
tracing:
  otlp:
    endpoint: "https://{your-collector-url}"
    headers:
      "X-Some-Header": "some-value"
```

#### Environment Variables

As of [v1.38.0](https://github.com/flipt-io/flipt/releases/tag/v1.38.0), we now allow users to provide OTLP specific resource environment variables that are part of the [OTLP spec](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/).

The following environment variables are supported:

* `OTEL_SERVICE_NAME` - Sets the value of the `service.name` resource attribute (default: `flipt`)
* `OTEL_RESOURCE_ATTRIBUTES` - Key-value pairs to be used as [resource attributes](https://opentelemetry.io/docs/specs/semconv/resource/#semantic-attributes-with-dedicated-environment-variable).
