Update emitter/prometheus.go to add 'team' and 'tags' field.
@@ -167,7 +167,7 @@ func (config *PrometheusConfig) NewEmitter() (metric.Emitter, error) {
Name: "containers",
Help: "Number of containers per worker",
},
- []string{"worker", "platform"},
+ []string{"worker", "platform", "team", "tags"},
)
prometheus.MustRegister(workerContainers)
@@ -178,7 +178,7 @@ func (config *PrometheusConfig) NewEmitter() (metric.Emitter, error) {
Name: "volumes",
Help: "Number of volumes per worker",
},
- []string{"worker", "platform"},
+ []string{"worker", "platform", "team", "tags"},
)
prometheus.MustRegister(workerVolumes)
@@ -448,6 +448,12 @@ func (emitter *PrometheusEmitter) workerContainersMetric(logger lager.Logger, ev
logger.Error("failed-to-find-platform-in-event", fmt.Errorf("expected platform to exist in event.Attributes"))
return
}
+ team, exists := event.Attributes["team"]
+ if !exists || team == "" {
+ logger.Error("failed-to-find-team-in-event", fmt.Errorf("expected team to exist in event.Attributes"))
+ return
+ }
+ tags, _ := event.Attributes["tags"]
containers, ok := event.Value.(int)
if !ok {
@@ -455,7 +461,7 @@ func (emitter *PrometheusEmitter) workerContainersMetric(logger lager.Logger, ev
return
}
- emitter.workerContainers.WithLabelValues(worker, platform).Set(float64(containers))
+ emitter.workerContainers.WithLabelValues(worker, platform, team, tags).Set(float64(containers))
}
func (emitter *PrometheusEmitter) workersRegisteredMetric(logger lager.Logger, event metric.Event) {
@@ -485,6 +491,12 @@ func (emitter *PrometheusEmitter) workerVolumesMetric(logger lager.Logger, event
logger.Error("failed-to-find-platform-in-event", fmt.Errorf("expected platform to exist in event.Attributes"))
return
}
+ team, exists := event.Attributes["team"]
+ if !exists || team == "" {
+ logger.Error("failed-to-find-team-in-event", fmt.Errorf("expected team to exist in event.Attributes"))
+ return
+ }
+ tags, _ := event.Attributes["tags"]
volumes, ok := event.Value.(int)
if !ok {
@@ -492,7 +504,7 @@ func (emitter *PrometheusEmitter) workerVolumesMetric(logger lager.Logger, event
return
}
- emitter.workerVolumes.WithLabelValues(worker, platform).Set(float64(volumes))
+ emitter.workerVolumes.WithLabelValues(worker, platform, team, tags).Set(float64(volumes))
}
func (emitter *PrometheusEmitter) httpResponseTimeMetrics(logger lager.Logger, event metric.Event) {
