registry_apm.go 719 B

12345678910111213141516171819202122232425262728293031
  1. package containers
  2. import (
  3. "fmt"
  4. "github.com/prometheus/client_golang/prometheus"
  5. )
  6. const (
  7. Namespace = "namespace"
  8. PodName = "pod_name"
  9. Workload = "workload"
  10. ProcessName = "process_name"
  11. )
  12. func setLabels(container_id, ns, pod_name, process_name, pid string) prometheus.Labels {
  13. return map[string]string{
  14. "container_id": container_id,
  15. "ns": ns,
  16. "pod_name": pod_name,
  17. "process_name": process_name,
  18. "pid": pid,
  19. }
  20. }
  21. func setK8sTag(c *Container, tag map[string]string, pid uint32) {
  22. sPid := fmt.Sprintf("%d", pid)
  23. c.K8sContainer.ns = tag[Namespace]
  24. c.K8sContainer.podName = tag[PodName]
  25. c.K8sContainer.containerName = tag[ProcessName]
  26. c.K8sContainer.pid = sPid
  27. }