mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: create gauges for all resource limits (#7718)
This PR adds Grafana gauges for all the existing resource limits. The
primary purpose is to be able to use this in alerting. Secondarily, we
can also use it to get better insights into how many customers have
increased their limits, as well as how many people are approaching their
limit, regdardless of whether it's been increased or not.
## Discussion points
### Implementation
The first approach I took (in
87528b4c67
),
was to add a new gauge for each resource limit. However, there's a lot
of boilerplate for it.
I thought doing it like this (the current implementation) would make it
easier. We should still be able to use the labelName to collate this in
Grafana, as far as I understand? As a bonus, we'd automatically get new
resource limits when we add them to the schema.
``` tsx
const resourceLimit = createGauge({
name: 'resource_limit',
help: 'The maximum number of resources allowed.',
labelNames: ['resource'],
});
// ...
for (const [resource, limit] of Object.entries(config.resourceLimits)) {
resourceLimit.labels({ resource }).set(limit);
}
```
That way, when checking the stats, we should be able to do something
like this:
``` promql
resource_limit{resource="constraintValues"}
```
### Do we need to reset gauges?
I noticed that we reset gauges before setting values in them all over
the place. I don't know if that's necessary. I'd like to get that double
clarified before merging this.
This commit is contained in:
parent
7db42453b1
commit
0c53f7d21b
@ -353,6 +353,12 @@ export default class MetricsMonitor {
|
||||
labelNames: ['type', 'method'],
|
||||
});
|
||||
|
||||
const resourceLimit = createGauge({
|
||||
name: 'resource_limit',
|
||||
help: 'The maximum number of resources allowed.',
|
||||
labelNames: ['resource'],
|
||||
});
|
||||
|
||||
async function collectStaticCounters() {
|
||||
try {
|
||||
const stats = await instanceStatsService.getStats();
|
||||
@ -509,6 +515,12 @@ export default class MetricsMonitor {
|
||||
.set(featureEnvironment.size);
|
||||
}
|
||||
|
||||
for (const [resource, limit] of Object.entries(
|
||||
config.resourceLimits,
|
||||
)) {
|
||||
resourceLimit.labels({ resource }).set(limit);
|
||||
}
|
||||
|
||||
enabledMetricsBucketsPreviousDay.reset();
|
||||
enabledMetricsBucketsPreviousDay.set(
|
||||
stats.previousDayMetricsBucketsCount.enabledCount,
|
||||
|
Loading…
Reference in New Issue
Block a user