Metrics Collector
Lunar can be easily set up to collect comprehensive metrics on the traffic passing through it. These metrics can then be exported to a metric server like Prometheus for utilization in dashboards and alerts.
Specific request or response headers can be selected and they will be a label in the exported metrics by using the request_header_names
and response_header_names
sections. It means the metrics can be filtered and aggregated based on different values of these headers.
For example, you can select the X-Group
header and the metrics will look like this:
lunar_transaction_sum{method="GET",normalized_url="provider1.com/users",request_X_Group="production",status_code="200"} 2286
lunar_transaction_sum{method="GET",normalized_url="provider1.com/users",request_X_Group="staging",status_code="200"} 2189
Additionally, specific counters can be defined to extract values from the request or response payloads using the counters
sections. These values will be stored as metrics and can be used for alerting or monitoring purposes.
For example, you can extract the value of the Retry-After
header from the response and store it as a metric, which will look like this:
lunar_response_headers_Retry_After_total{method="GET",normalized_url="provider1.com/users",status_code="429"} 20845
lunar_response_headers_Retry_After_total{method="GET",normalized_url="provider2.com/posts",status_code="429"} 24199