Configuration

MetricFlow can be configured via a YAML configuration file, environment variables, or programmatically. The configuration file is the recommended approach for production deployments.

Configuration File

By default, MetricFlow looks for metricflow.yaml in the current working directory. You can specify a custom path:

mf = metricflow.init(config="/etc/metricflow/config.yaml")

Full Configuration Example

# MetricFlow Configuration
# See https://metricflow.org/docs/configuration.html

global:
  prefix: "myapp"
  interval: 15
  default_labels:
    environment: "production"
    service: "api-gateway"

exporter:
  type: "prometheus"
  prometheus:
    port: 9090
    path: "/metrics"

  # Alternative: StatsD exporter
  # type: "statsd"
  # statsd:
  #   host: "localhost"
  #   port: 8125
  #   prefix: "myapp"
  #   protocol: "udp"

  # Alternative: OTLP exporter
  # type: "otlp"
  # otlp:
  #   endpoint: "http://localhost:4317"
  #   protocol: "grpc"
  #   headers:
  #     authorization: "Bearer ${OTLP_TOKEN}"

logging:
  level: "info"
  format: "json"

Exporter Configuration

Prometheus

Parameter Type Default Description
port int 9090 HTTP server port for metrics endpoint
path str "/metrics" URL path for metrics endpoint

StatsD

Parameter Type Default Description
host str "localhost" StatsD server hostname
port int 8125 StatsD server port
prefix str "" Metric name prefix
protocol str "udp" Transport protocol (udp or tcp)

OTLP

Parameter Type Default Description
endpoint str "http://localhost:4317" OTLP collector endpoint
protocol str "grpc" Transport protocol (grpc or http)
headers dict {} Additional request headers

Environment Variables

All configuration options can be overridden with environment variables. The format is METRICFLOW_ followed by the uppercased key path with underscores.

Variable Config Path Example
METRICFLOW_GLOBAL_PREFIX global.prefix "myapp"
METRICFLOW_GLOBAL_INTERVAL global.interval 15
METRICFLOW_EXPORTER_TYPE exporter.type "prometheus"
METRICFLOW_EXPORTER_PROMETHEUS_PORT exporter.prometheus.port 9090
METRICFLOW_LOG_LEVEL logging.level "debug"