Skip to content

Commit 6062f8c

Browse files
authored
Add support for metricNamespace on cross-resource queries (#54)
1 parent cc63a1b commit 6062f8c

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,23 @@ azurerm_ratelimit{scope="subscription",subscriptionID="...",type="read"} 11999
301301

302302
one metric request per subscription and region
303303

304-
| GET parameter | Default | Required | Multiple | Description |
305-
|-----------------|---------------------------|----------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------|
306-
| `subscription` | | **yes** | **yes** | Azure Subscription ID |
307-
| `region` | | **yes** | **yes** | Azure Regions (eg. `westeurope`, `northeurope`) |
308-
| `resourceType` | | **yes** | no | Azure Resource type |
309-
| `timespan` | `PT1M` | no | no | Metric timespan |
310-
| `interval` | | no | no | Metric timespan |
311-
| `metric` | | no | **yes** | Metric name |
312-
| `aggregation` | | no | **yes** | Metric aggregation (`minimum`, `maximum`, `average`, `total`, `count`, multiple possible separated with `,`) |
313-
| `name` | `azurerm_resource_metric` | no | no | Prometheus metric name |
314-
| `metricFilter` | | no | no | Prometheus metric filter (dimension support; supports only 2 filters in subscription query mode as the first filter is used to split by resource id) |
315-
| `metricTop` | | no | no | Prometheus metric dimension count (dimension support) |
316-
| `metricOrderBy` | | no | no | Prometheus metric order by (dimension support) |
317-
| `cache` | (same as timespan) | no | no | Use of internal metrics caching |
318-
| `template` | set to `$METRIC_TEMPLATE` | no | no | see [metric name and help template system](#metric-name-and-help-template-system) |
319-
| `help` | set to `$METRIC_HELP` | no | no | see [metric name and help template system](#metric-name-and-help-template-system) |
304+
| GET parameter | Default | Required | Multiple | Description |
305+
|-------------------|---------------------------|----------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------|
306+
| `subscription` | | **yes** | **yes** | Azure Subscription ID |
307+
| `region` | | **yes** | **yes** | Azure Regions (eg. `westeurope`, `northeurope`) |
308+
| `resourceType` | | **yes** | no | Azure Resource type |
309+
| `timespan` | `PT1M` | no | no | Metric timespan |
310+
| `interval` | | no | no | Metric timespan |
311+
| `metricNamespace` | | no | no | Metric namespace |
312+
| `metric` | | no | **yes** | Metric name |
313+
| `aggregation` | | no | **yes** | Metric aggregation (`minimum`, `maximum`, `average`, `total`, `count`, multiple possible separated with `,`) |
314+
| `name` | `azurerm_resource_metric` | no | no | Prometheus metric name |
315+
| `metricFilter` | | no | no | Prometheus metric filter (dimension support; supports only 2 filters in subscription query mode as the first filter is used to split by resource id) |
316+
| `metricTop` | | no | no | Prometheus metric dimension count (dimension support) |
317+
| `metricOrderBy` | | no | no | Prometheus metric order by (dimension support) |
318+
| `cache` | (same as timespan) | no | no | Use of internal metrics caching |
319+
| `template` | set to `$METRIC_TEMPLATE` | no | no | see [metric name and help template system](#metric-name-and-help-template-system) |
320+
| `help` | set to `$METRIC_HELP` | no | no | see [metric name and help template system](#metric-name-and-help-template-system) |
320321

321322
*Hint: Multiple values can be specified multiple times or with a comma in a single value.*
322323

metrics/prober.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ func (p *MetricProber) collectMetricsFromSubscriptions() {
223223
opts.Orderby = to.StringPtr(p.settings.MetricOrderBy)
224224
}
225225

226+
if len(p.settings.MetricNamespace) >= 1 {
227+
opts.Metricnamespace = to.StringPtr(p.settings.MetricNamespace)
228+
}
229+
226230
response, err := client.ListAtSubscriptionScope(p.ctx, region, &opts)
227231
if err != nil {
228232
// FIXME: find a better way to report errors

templates/query.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ <h3>Service Discovery</h3>
238238
</div>
239239
</div>
240240

241-
<div class="mb-3 row" query-endpoint-exclude="/probe/metrics">
241+
<div class="mb-3 row">
242242
<label for="metricNamespace" class="col-sm-2 col-form-label">metricNamespace</label>
243243
<div class="col-sm-10">
244244
<input type="text" class="form-control" id="metricNamespace">

0 commit comments

Comments
 (0)