【发布时间】:2018-11-05 12:27:36
【问题描述】:
我试图弄清楚如何将 map[string]string 的键值对添加到我的 prometheus.Labels 结构中。
如果您有使用 prometheus 的经验:我正在尝试动态添加标签及其值。
labelsMap := make(map[string]string)
labelsMap["nodepool"] = "default"
labelsMap["zone"] = "europe-west"
// here I'd like to add my key / value pairs from my map
containerLabels := prometheus.Labels{
"node": "nodename",
"container": "foo",
"qos": "bar",
}
requestedContainerCPUCoresGauge.With(containerLabels).Set(containerMetric.RequestedCPUCores)
我的问题:
如何从给定映射 labelsMap 中动态添加键/值对到我的 containerLabels 中?
【问题讨论】:
标签: dictionary go prometheus