Skip to content

Commit e0c7586

Browse files
[FSSDK-9434] doc: update readme with Prometheus metrics doc (#412)
* update readme with prometheus metrics doc * Update README.md Co-authored-by: Mike Chu <[email protected]> * Update README.md Co-authored-by: Mike Chu <[email protected]> * Update README.md Co-authored-by: Mike Chu <[email protected]> * Update README.md Co-authored-by: Mike Chu <[email protected]> --------- Co-authored-by: Mike Chu <[email protected]>
1 parent c563262 commit e0c7586

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

README.md

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,28 @@ This endpoint can used when placing Agent behind a load balancer to indicate whe
236236

237237
### Metrics
238238

239-
The `/metrics` endpoint exposes telemetry data of the running Optimizely Agent. The core runtime metrics are exposed via the go expvar package. Documentation for the various statistics can be found as part of the [mstats](https://go.dev/src/runtime/mstats.go) package.
239+
The `/metrics` endpoint exposes telemetry data of the running Optimizely Agent.
240+
241+
Currently, Agent exposes two type of metrics data (expvar or prometheus) based on user's input. By default, expvar metrics will be used. To configure this, update config.yaml or
242+
set the value of the environment variable `OPTIMIZELY_ADMIN_METRICSTYPE`. Supported values are `expvar` (default) & `promethues`.
243+
244+
```yaml
245+
##
246+
## admin service configuration
247+
##
248+
admin:
249+
## http listener port
250+
port: "8088"
251+
## metrics package to use
252+
## supported packages are expvar and prometheus
253+
## default is expvar
254+
metricsType: ""
255+
## metricsType: "promethues" ## for prometheus metrics
256+
```
257+
258+
#### Expvar metrics
259+
260+
The core runtime metrics are exposed via the Go expvar package. Documentation for the various statistics can be found as part of the [mstats](https://go.dev/src/runtime/mstats.go) package.
240261

241262
Example Request:
242263

@@ -276,6 +297,80 @@ Custom metrics are also provided for the individual service endpoints and follow
276297
"timers.<metric-name>.responseTimeHist.p99": 0,
277298
```
278299

300+
#### Prometheus metrics
301+
302+
Optimizely Agent also supports Prometheus metrics. Prometheus is an open-source toolkit for monitoring and alerting. You can use it to collect and visualize metrics in a time-series database.
303+
304+
To access the Prometheus metrics, you can use the `/metrics` endpoint with a Prometheus server. The metrics are exposed in a format that Prometheus can scrape and aggregate.
305+
306+
Example Request:
307+
308+
```bash
309+
curl localhost:8088/metrics
310+
```
311+
312+
This will return a plain text response in the Prometheus Exposition Format, which includes all the metrics that Prometheus is currently tracking.
313+
314+
Please note that you need to configure your Prometheus server to scrape metrics from this endpoint.
315+
316+
For more information on how to use Prometheus for monitoring, you can refer to the [official Prometheus documentation](https://prometheus.io/docs/introduction/overview/).
317+
318+
Example Response:
319+
320+
```
321+
...
322+
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
323+
# TYPE promhttp_metric_handler_requests_total counter
324+
promhttp_metric_handler_requests_total{code="200"} 1
325+
promhttp_metric_handler_requests_total{code="500"} 0
326+
promhttp_metric_handler_requests_total{code="503"} 0
327+
# HELP timer_decide_hits
328+
# TYPE timer_decide_hits counter
329+
timer_decide_hits 1
330+
# HELP timer_decide_response_time
331+
# TYPE timer_decide_response_time counter
332+
timer_decide_response_time 658.109
333+
# HELP timer_decide_response_time_hist
334+
# TYPE timer_decide_response_time_hist histogram
335+
timer_decide_response_time_hist_bucket{le="0.005"} 0
336+
timer_decide_response_time_hist_bucket{le="0.01"} 0
337+
timer_decide_response_time_hist_bucket{le="0.025"} 0
338+
timer_decide_response_time_hist_bucket{le="0.05"} 0
339+
timer_decide_response_time_hist_bucket{le="0.1"} 0
340+
timer_decide_response_time_hist_bucket{le="0.25"} 0
341+
timer_decide_response_time_hist_bucket{le="0.5"} 0
342+
timer_decide_response_time_hist_bucket{le="1"} 0
343+
timer_decide_response_time_hist_bucket{le="2.5"} 0
344+
timer_decide_response_time_hist_bucket{le="5"} 0
345+
timer_decide_response_time_hist_bucket{le="10"} 0
346+
timer_decide_response_time_hist_bucket{le="+Inf"} 1
347+
timer_decide_response_time_hist_sum 658.109
348+
timer_decide_response_time_hist_count 1
349+
# HELP timer_track_event_hits
350+
# TYPE timer_track_event_hits counter
351+
timer_track_event_hits 1
352+
# HELP timer_track_event_response_time
353+
# TYPE timer_track_event_response_time counter
354+
timer_track_event_response_time 0.356334
355+
# HELP timer_track_event_response_time_hist
356+
# TYPE timer_track_event_response_time_hist histogram
357+
timer_track_event_response_time_hist_bucket{le="0.005"} 0
358+
timer_track_event_response_time_hist_bucket{le="0.01"} 0
359+
timer_track_event_response_time_hist_bucket{le="0.025"} 0
360+
timer_track_event_response_time_hist_bucket{le="0.05"} 0
361+
timer_track_event_response_time_hist_bucket{le="0.1"} 0
362+
timer_track_event_response_time_hist_bucket{le="0.25"} 0
363+
timer_track_event_response_time_hist_bucket{le="0.5"} 1
364+
timer_track_event_response_time_hist_bucket{le="1"} 1
365+
timer_track_event_response_time_hist_bucket{le="2.5"} 1
366+
timer_track_event_response_time_hist_bucket{le="5"} 1
367+
timer_track_event_response_time_hist_bucket{le="10"} 1
368+
timer_track_event_response_time_hist_bucket{le="+Inf"} 1
369+
timer_track_event_response_time_hist_sum 0.356334
370+
timer_track_event_response_time_hist_count 1
371+
...
372+
```
373+
279374
### Profiling
280375

281376
Agent exposes the runtime profiling data in the format expected by the [pprof](https://github.com/google/pprof/blob/master/doc/README.md) visualization tool.

0 commit comments

Comments
 (0)