Skip to content

Commit

Permalink
[receiver/haproxyreceiver] add more metrics (#17845)
Browse files Browse the repository at this point in the history
* [receiver/haproxyreceiver] add more metrics

* add more checks and use enum
  • Loading branch information
atoulme authored Jan 23, 2023
1 parent 7c8f3e2 commit 099a00f
Show file tree
Hide file tree
Showing 9 changed files with 2,826 additions and 223 deletions.
16 changes: 16 additions & 0 deletions .chloggen/add-haproxy-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: haproxyreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add new metrics to the haproxyreceiver

# One or more tracking issues related to the change
issues: [16829]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
208 changes: 194 additions & 14 deletions receiver/haproxyreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,131 @@ metrics:
enabled: false
```
### haproxy.connection_rate
### haproxy.bytes.input
Bytes in. Corresponds to HAProxy's `bin` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| by | Sum | Int | Cumulative | true |

### haproxy.bytes.output

Bytes out. Corresponds to HAProxy's `bout` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| by | Sum | Int | Cumulative | true |

### haproxy.connections.errors

Number of requests that encountered an error trying to connect to a backend server. The backend stat is the sum of the stat. Corresponds to HAProxy's `econ` metric

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {errors} | Sum | Int | Cumulative | true |

### haproxy.connections.rate

Number of connections over the last elapsed second (frontend). Corresponds to HAProxy's `conn_rate` metric.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {connections} | Gauge | Int |

### haproxy.idle_percent
### haproxy.connections.retries

Number of times a connection to a server was retried. Corresponds to HAProxy's `wretr` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {retries} | Sum | Int | Cumulative | true |

### haproxy.requests.denied

Requests denied because of security concerns. Corresponds to HAProxy's `dreq` metric

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {requests} | Sum | Int | Cumulative | true |

### haproxy.requests.errors

Cumulative number of request errors. Corresponds to HAProxy's `ereq` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {errors} | Sum | Int | Cumulative | true |

### haproxy.requests.queued

Ratio of system polling time versus total time. Corresponds to HAProxy's `Idle_pct` metric.
Current queued requests. For the backend this reports the number queued without a server assigned. Corresponds to HAProxy's `qcur` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {requests} | Sum | Int | Cumulative | true |

### haproxy.requests.rate

HTTP requests per second over last elapsed second. Corresponds to HAProxy's `req_rate` metric.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {percent} | Gauge | Double |
| {requests} | Gauge | Double |

### haproxy.requests.redispatched

Number of times a request was redispatched to another server. Corresponds to HAProxy's `wredis` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {requests} | Sum | Int | Cumulative | true |

### haproxy.requests.total

Total number of HTTP requests received. Corresponds to HAProxy's `req_tot`, `hrsp_1xx`, `hrsp_2xx`, `hrsp_3xx`, `hrsp_4xx`, `hrsp_5xx` and `hrsp_other` metrics.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {requests} | Sum | Int | Cumulative | true |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| proxy_name | Proxy name | Any Str |
| service_name | Service name (FRONTEND for frontend, BACKEND for backend, any name for server/listener) | Any Str |
| status_code | Status code category, 1xx, 2xx, 3xx, 4xx, 5xx or other | Str: ``1xx``, ``2xx``, ``3xx``, ``4xx``, ``5xx``, ``other`` |

### haproxy.requests
### haproxy.responses.denied

Total number of requests on this worker process since started. Corresponds to HAProxy's `CumReq` metric.
Responses denied because of security concerns. Corresponds to HAProxy's `dresp` metric

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {requests} | Sum | Int | Cumulative | true |
| {responses} | Sum | Int | Cumulative | true |

### haproxy.responses.errors

Cumulative number of response errors. Corresponds to HAProxy's `eresp` metric, `srv_abrt` will be counted here also.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {errors} | Sum | Int | Cumulative | true |

### haproxy.server_selected.total

Number of times a server was selected, either for new sessions or when re-dispatching. Corresponds to HAProxy's `lbtot` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {selections} | Sum | Int | Cumulative | true |

### haproxy.sessions.average

Average total session time in ms over the last 1024 requests. Corresponds to HAProxy's `ttime` metric.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| ms | Gauge | Double |

### haproxy.sessions.count

Expand All @@ -51,12 +146,95 @@ Current sessions. Corresponds to HAProxy's `scur` metric.
| ---- | ----------- | ---------- |
| {sessions} | Gauge | Int |

#### Attributes
### haproxy.sessions.rate

| Name | Description | Values |
| ---- | ----------- | ------ |
| proxy_name | Proxy name | Any Str |
| service_name | Service name (FRONTEND for frontend, BACKEND for backend, any name for server/listener) | Any Str |
Number of sessions per second over last elapsed second. Corresponds to HAProxy's `rate` metric.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {sessions} | Gauge | Double |

## Optional Metrics

The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration:

```yaml
metrics:
<metric_name>:
enabled: true
```

### haproxy.clients.canceled

Number of data transfers aborted by the client. Corresponds to HAProxy's `cli_abrt` metric

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {cancellations} | Sum | Int | Cumulative | true |

### haproxy.compression.bypass

Number of bytes that bypassed the HTTP compressor (CPU/BW limit). Corresponds to HAProxy's `comp_byp` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| by | Sum | Int | Cumulative | true |

### haproxy.compression.count

Number of HTTP responses that were compressed. Corresponds to HAProxy's `comp_rsp` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {responses} | Sum | Int | Cumulative | true |

### haproxy.compression.input

Number of HTTP response bytes fed to the compressor. Corresponds to HAProxy's `comp_in` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| by | Sum | Int | Cumulative | true |

### haproxy.compression.output

Number of HTTP response bytes emitted by the compressor. Corresponds to HAProxy's `comp_out` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| by | Sum | Int | Cumulative | true |

### haproxy.connections.total

Cumulative number of connections (frontend). Corresponds to HAProxy's `conn_tot` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {connections} | Sum | Int | Cumulative | true |

### haproxy.downtime

Total downtime (in seconds). The value for the backend is the downtime for the whole backend, not the sum of the server downtime. Corresponds to HAProxy's `downtime` metric

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |

### haproxy.failed_checks

Number of failed checks. (Only counts checks failed when the server is up). Corresponds to HAProxy's `chkfail` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {checks} | Sum | Int | Cumulative | true |

### haproxy.sessions.total

Cumulative number of sessions. Corresponds to HAProxy's `stot` metric.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {sessions} | Sum | Int | Cumulative | true |

## Resource Attributes

Expand All @@ -69,3 +247,5 @@ Current sessions. Corresponds to HAProxy's `scur` metric.
| haproxy.sid | server id (unique inside a proxy) | Any Str | true |
| haproxy.type | (0=frontend, 1=backend, 2=server, 3=socket/listener) | Any Str | true |
| haproxy.url | The path to the HAProxy socket or HTTP URL. | Any Str | true |
| proxy_name | Proxy name | Any Str | false |
| service_name | Service name (FRONTEND for frontend, BACKEND for backend, any name for server/listener) | Any Str | false |
2 changes: 1 addition & 1 deletion receiver/haproxyreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
go.opentelemetry.io/collector/confmap v0.69.2-0.20230121222757-51c9139d1c2f
go.opentelemetry.io/collector/consumer v0.69.2-0.20230121222757-51c9139d1c2f
go.opentelemetry.io/collector/pdata v1.0.0-rc3.0.20230121222757-51c9139d1c2f
go.uber.org/multierr v1.9.0
go.uber.org/zap v1.24.0
)

Expand Down Expand Up @@ -37,7 +38,6 @@ require (
go.opentelemetry.io/otel/metric v0.34.0 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
Expand Down
Loading

0 comments on commit 099a00f

Please sign in to comment.