Project: Open Policy Agent (OPA) (Provisioning / Security & Compliance)
File: monitoring.md

title: Monitoring kind: operations weight: 30 restrictedtoc: true When run as a server and configured accordingly, OPA will emit spans to an collector via gRPC. Each request sent to the server will start a span. If processing the request involves policy evaluation, and that in turn uses , those HTTP clients will emit descendant spans. Furthermore, spans exported for policy evaluation requests will contain an attribute `opa.decisionid` of the evaluation's decision ID if_ the server has decision logging enabled. See for all OpenTelemetry-related configurables. OPA exposes an HTTP endpoint that can be used to collect performance metrics for all API calls. The Prometheus endpoint is enabled by default when you run OPA as a server. You can enable metric collection from OPA with the following `prometheus.yml` config: ```yaml global: scrape_interval: 15s scrape_configs: job_name: "opa" metrics_path: "/metrics" static_configs: targets: "localhost:8181" ``` The Prometheus endpoint exports Go runtime metrics as well as HTTP request latency metrics for all handlers (e.g., `v1/data`). | Metric name | Metric type | Description | Status | | | | | | | gogcduration_seconds | summary | A summary of the GC invocation durations. | STABLE | | go_goroutines | gauge | Number of goroutines that currently exist. | STABLE | | go_info | gauge | Information about the Go environment. | STABLE | | gomemstatsalloc_bytes | gauge | Number of bytes allocated and still in use. | STABLE | | gomemstatsallocbytestotal | counter | Total number of bytes allocated, even if freed. | STABLE | | gomemstatsbuckhashsys_bytes | gauge | Number of bytes used by the profiling bucket hash table. | STABLE | | gomemstatsfrees_total | counter | Total number of frees. | STABLE | | gomemstatsgccpufraction | gauge | The fraction of this program's available CPU time used by the GC since the program started. | STABLE | | gomemstatsgcsysbytes | gauge | Number of bytes used for garbage collection system metadata. | STABLE | | gomemstatsheapallocbytes | gauge | Number of heap bytes allocated and still in use. | STABLE | | gomemstatsheapidlebytes | gauge | Number of heap bytes waiting to be used. | STABLE | | gomemstatsheapinusebytes | gauge | Number of heap bytes that are in use. | STABLE | | gomemstatsheap_objects | gauge | Number of allocated objects. | STABLE | | gomemstatsheapreleasedbytes | gauge | Number of heap bytes released to OS. | STABLE | | gomemstatsheapsysbytes | gauge | Number of heap bytes obtained from

| STABLE | | gomemstatslastgctime_seconds | gauge | Number of seconds since 1970 of last garbage collection. | STABLE | | gomemstatslookups_total | counter | Total number of pointer lookups. | STABLE | | gomemstatsmallocs_total | counter | Total number of mallocs. | STABLE | | gomemstatsmcacheinusebytes | gauge | Number of bytes in use by mcache structures. | STABLE | | gomemstatsmcachesysbytes | gauge | Number of bytes used for mcache structures obtained from system. | STABLE | | gomemstatsmspaninusebytes | gauge | Number of bytes in use by mspan structures. | STABLE | | gomemstatsmspansysbytes | gauge | Number of bytes used for mspan structures obtained from system. | STABLE | | gomemstatsnextgcbytes | gauge | Number of heap bytes when next garbage collection will take place. | STABLE | | gomemstatsothersysbytes | gauge | Number of bytes used for other system allocations. | STABLE | | gomemstatsstackinusebytes | gauge | Number of bytes in use by the stack allocator. | STABLE | | gomemstatsstacksysbytes | gauge | Number of bytes obtained from system for stack allocator. | STABLE | | gomemstatssys_bytes | gauge | Number of bytes obtained from system. | STABLE | | go_threads | gauge | Number of OS threads created. | STABLE | | httprequestduration_seconds | histogram | A histogram of duration for requests. | STABLE | When Prometheus is enabled in the status plugin (see ), the OPA instance's Prometheus endpoint also exposes these metrics: | Metric name | Metric type | Description | Status | | | |-|--| | opa_info | gauge | Information about the OPA environment. | STABLE | | pluginstatusgauge | gauge | Number of plugins by name and status. | STABLE | | bundleloadedcounter | counter | Number of bundles loaded with success. | STABLE | | bundlefailedload_counter | counter | Number of bundles that failed to load. | STABLE | | lastbundlerequest | gauge | Last bundle request in UNIX nanoseconds. | STABLE | | lastsuccessbundle_activation | gauge | Last successful bundle activation in UNIX nanoseconds. | STABLE | | lastsuccessbundle_download | gauge | Last successful bundle download in UNIX nanoseconds. | STABLE | | lastsuccessbundle_request | gauge | Last successful bundle request in UNIX nanoseconds. | STABLE | | bundleloadingduration_ns | histogram | A histogram of duration for bundle loading. | STABLE | OPA exposes a `/health` API endpoint that can be used to perform health checks. See for details. OPA provides a plugin which can push status to a remote service. See for details.