Skip to content

Commit 9963b6d

Browse files
LucasRoesleralexellis
authored andcommitted
Add metrics reference page with examples
**What** - Add reference documentation for the metrics exposed by the gateway - Include examples for the usage of those metrics Signed-off-by: Lucas Roesler <[email protected]>
1 parent 542c67a commit 9963b6d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

docs/reference/metrics.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Monitoring Functions
2+
3+
The Gateway component exposes several metrics to help you monitor the health and behavior of your functions
4+
5+
| Metric | Type | Description | Labels |
6+
| ----------------------------------- | --------- | ------------------------------ | ----------------------- |
7+
| `gateway_functions_seconds` | histogram | Function invocation time taken | `function_name` |
8+
| `gateway_function_invocation_total` | counter | Function invocation count | `function_name`, `code` |
9+
| `gateway_service_count` | counter | Number of function replicas | `function_name` |
10+
11+
## Examples
12+
13+
These basic metrics can be used to track the health of your functions as well a general usage patterns. See the Prometheus [documentation][prom-query-basics] and [examples][prom-query-examples] for more details about the available options and query functions. Below are several queries you might want to include in a basic [Grafana](https://grafana.com) dashboard for observing your OpenFaaS functions
14+
15+
### Function invocation rate
16+
17+
Return the per-second rate of invocation as measured over the previous 20 seconds:
18+
19+
```
20+
rate ( gateway_function_invocation_total [20s])
21+
```
22+
23+
### Function replica count / scaling
24+
25+
Return the total function replicas:
26+
27+
```
28+
gateway_service_count
29+
```
30+
31+
### Total OK Function Invocation
32+
33+
Return the total number of successful function invocations:
34+
35+
```
36+
sum( gateway_function_invocation_total { code=\"200\"}
37+
```
38+
39+
### Function execution time
40+
41+
Return the average function execution time, as measure over the previous 20 seconds:
42+
43+
```
44+
(rate(gateway_functions_seconds_sum[20s]) / rate(gateway_functions_seconds_count[20s]))
45+
```
46+
47+
[prom-query-basics]: https://prometheus.io/docs/prometheus/latest/querying/basics/
48+
[prom-query-examples]: https://prometheus.io/docs/prometheus/latest/querying/examples/

0 commit comments

Comments
 (0)