This repository has been archived by the owner on Feb 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
ContainerTrackerMetrics.cs
42 lines (35 loc) · 1.83 KB
/
ContainerTrackerMetrics.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Prometheus;
using System;
namespace DockerExporter
{
sealed class ContainerTrackerMetrics : IDisposable
{
public Counter.Child FailedProbeCount { get; }
// These two are NOT differentiated by container, just to avoid a large number of series for each container.
// Aggregate results seem useful, container scope less so. Can be expanded in the future if need be.
public Histogram InspectContainerDuration => BaseInspectContainerDuration;
public Histogram GetResourceStatsDuration => BaseGetResourceStatsDuration;
public ContainerTrackerMetrics(string displayName)
{
FailedProbeCount = BaseFailedProbeCount.WithLabels(displayName);
}
public void Dispose()
{
FailedProbeCount.Remove();
}
private static readonly Counter BaseFailedProbeCount = Metrics.CreateCounter("docker_probe_container_failed_total", "Number of times the exporter failed to collect information about a specific container.", new CounterConfiguration
{
LabelNames = new[] { "name" }
});
private static readonly Histogram BaseInspectContainerDuration = Metrics
.CreateHistogram("docker_probe_inspect_duration_seconds", "How long it takes to query Docker for the basic information about a single container. Includes failed requests.", new HistogramConfiguration
{
Buckets = Constants.DurationBuckets
});
private static readonly Histogram BaseGetResourceStatsDuration = Metrics
.CreateHistogram("docker_probe_stats_duration_seconds", "How long it takes to query Docker for the resource usage of a single container. Includes failed requests.", new HistogramConfiguration
{
Buckets = Constants.DurationBuckets
});
}
}