You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/mdatagen/README.md
+88Lines changed: 88 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,94 @@ The `config` section is based on [JSON Schema standard](https://json-schema.org/
98
98
- **Reusable definitions**: Define common schemas in `$defs` and reference them with `$ref`
99
99
- **Schema composition**: Use `allOf` for complex configurations
100
100
101
+
### Metrics Builder Configuration
102
+
103
+
For receivers, scrapers, and other components that emit metrics, `mdatagen` can generate metrics builder
104
+
configuration from `metadata.yaml`.
105
+
106
+
```yaml
107
+
type: myreceiver
108
+
status:
109
+
class: receiver
110
+
stability:
111
+
beta: [metrics]
112
+
113
+
resource_attributes:
114
+
transport:
115
+
description: Transport used by the request.
116
+
type: string
117
+
enabled: true
118
+
119
+
attributes:
120
+
status_code:
121
+
description: Response status code.
122
+
type: int
123
+
requirement_level: opt_in
124
+
125
+
metrics:
126
+
http.server.request.count:
127
+
enabled: true
128
+
description: Number of received requests.
129
+
unit: "{request}"
130
+
sum:
131
+
value_type: int
132
+
monotonic: true
133
+
aggregation_temporality: cumulative
134
+
attributes: [status_code]
135
+
```
136
+
137
+
This lets users:
138
+
139
+
- enable or disable individual metrics
140
+
- enable or disable resource attributes
141
+
- use `metrics_include` and `metrics_exclude` on resource attributes to only emit metrics with matching resource attribute values
142
+
143
+
### Metric Reaggregation Configuration
144
+
145
+
Set `reaggregation_enabled: true` to let users reduce metric cardinality by dropping selected metric
146
+
attributes and aggregating the resulting datapoints.
147
+
148
+
```yaml
149
+
reaggregation_enabled: true
150
+
151
+
attributes:
152
+
transport:
153
+
description: Transport used by the request.
154
+
type: string
155
+
requirement_level: recommended
156
+
status_code:
157
+
description: Response status code.
158
+
type: int
159
+
requirement_level: opt_in
160
+
```
161
+
162
+
This adds two per-metric settings for metrics that declare attributes:
163
+
164
+
- `attributes`: the subset of metric attributes to keep in the emitted metric stream
165
+
- `aggregation_strategy`: how collapsed datapoints are merged, using `sum`, `avg`, `min`, or `max`
166
+
167
+
Defaults:
168
+
169
+
- sum metrics use `sum`; gauge metrics use `avg`
170
+
- `required`attributes are always kept
171
+
- `recommended`and `conditionally_required` attributes are kept by default, but users can remove them
172
+
- `opt_in`attributes are omitted by default, so that dimension is aggregated unless the user adds it
173
+
174
+
Example user configuration:
175
+
176
+
```yaml
177
+
receivers:
178
+
myreceiver:
179
+
metrics:
180
+
http.server.request.count:
181
+
enabled: true
182
+
aggregation_strategy: sum
183
+
attributes: [transport]
184
+
```
185
+
186
+
In this example, datapoints that only differ by `status_code` are aggregated together, while
187
+
`transport`remains part of the output identity.
188
+
101
189
### Feature Gates Documentation
102
190
103
191
The metadata generator supports automatic documentation generation for feature gates used by components. Feature gates are documented by adding a `feature_gates` section to your `metadata.yaml`:
0 commit comments