Skip to main content

Monitor the proxy using Prometheus

The proxy uses Prometheus for recording metrics that can be used to understand how the proxy is behaving and performing. You can view and scrape these metrics by hitting the proxy's /metrics endpoint. For example, if you're running the proxy locally on port 7000, you can view the metrics it exposes by making the following request:

$ curl localhost:7000/metrics

Example Queries

To get started, here are some example promql queries that can be useful for monitoring how the proxy is performing.

UsecasePromql query
Request Rate by Status Codesum by (code) (rate(ff_proxy_http_requests_total[5m]))
Requests Rate by URLsum by (url) ( rate ( ff_proxy_http_requests_total[5m]))
Cache Writessum by (error) (rate(ff_proxy_redis_cache_write_count[5m]))
Cache Readssum by (error) (rate(ff_proxy_redis_cache_read_count[5m]))
Cache Deletessum by (error) (rate(ff_proxy_redis_cache_read_count[5m]))
SSE Events Forwardedsum by (error) (rate(ff_proxy_sse_publish[5m]))
SSE Streams Closedsum by (error) (rate(ff ff_proxy_sse_stream_close[5m]))

As well as counter metrics, the proxy also exposes a number of histogram metrics that can be used to monitor request duration, payload sizes, and how long interactions with the cache take. If you are unfamilar with histogram metrics, we recommend reading this article for help with visualising histograms.

Example Prometheus Configuration

Below is an example prometheus configuration that can be used to scrape metrics from the proxy.

global:
scrape_interval: 10s
evaluation_interval: 10s

scrape_configs:
- job_name: 'prometheus'
scrape_interval: 30s
static_configs:
- targets: ['localhost:7000']

Metrics exposed

Below is a list of all the prometheus metrics exposed by the proxy.

NameTypeLabelsDescription
ff_proxy_http_requests_totalcountercode: The HTTP response code

envID: The environmentID

method: The HTTP method used for the request

url: The requests URL
Records the number of requests to an endpoint
ff_proxy_http_requests_durationhistogramenvID: The environmentID

url: The requests URL
Records the request duration for an endpoint
ff_http_requests_content_length_histogramhistogramenvID: The environmentID

url: The requests URL
Records the value of the Content-Length header for an HTTP request
ff_proxy_metrics_forwardedcounterenvID: The environmentID

error: Indicates if an error occurred during forwarding
Tracks the number of metrics forwarded from the proxy to SaaS Feature Flags
ff_proxy_sdk_usagecounterenvID: The environment ID

sdk_language: The programming language of the SDK

sdk_type: The type of the SDK (e.g., server, client, mobile)

sdk_version: The version of the SDK
Tracks what SDKs are using the FF proxy
ff_proxy_sse_publishcounterapi_key: The API key used for authentication

environment: The environment ID

error: Indicates whether an error occurred during event forwarding
Records the number of Server-Sent Events (SSE) the proxy has received and forwarded on to clients
ff_proxy_sse_stream_closecounterapi_key: The API key used for authentication

environment: The environment ID

error: Indicates whether an error occurred during event forwarding
Records the number of times the proxy closes an SSE stream
ff_proxy_redis_cache_read_countcountererror: Indicates if an error occurred during the read operation

key: The cache key used for the read operation

Tracks how many reads are made to the cache
ff_proxy_redis_cache_write_countcountererror: Indicates whether an error occurred during the write operation

key: The cache key

Tracks how many writes are made to the cache
ff_proxy_redis_cache_remove_countcounterkey: The cache key

Tracks how many deletes are made to the cache
ff_proxy_redis_cache_delete_durationhistogramN/ATracks how long delete operations to the cache take
ff_proxy_redis_cache_write_durationhistogramN/ATracks how long write operations to the cache take
ff_proxy_redis_cache_read_durationhistogramN/ATracks how long write operations to the cache take