Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
39
plugins/inputs/kube_inventory/deployment.go
Normal file
39
plugins/inputs/kube_inventory/deployment.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package kube_inventory
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"k8s.io/api/apps/v1"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
)
|
||||
|
||||
func collectDeployments(ctx context.Context, acc telegraf.Accumulator, ki *KubernetesInventory) {
|
||||
list, err := ki.client.getDeployments(ctx)
|
||||
if err != nil {
|
||||
acc.AddError(err)
|
||||
return
|
||||
}
|
||||
for i := range list.Items {
|
||||
ki.gatherDeployment(&list.Items[i], acc)
|
||||
}
|
||||
}
|
||||
|
||||
func (ki *KubernetesInventory) gatherDeployment(d *v1.Deployment, acc telegraf.Accumulator) {
|
||||
fields := map[string]interface{}{
|
||||
"replicas_available": d.Status.AvailableReplicas,
|
||||
"replicas_unavailable": d.Status.UnavailableReplicas,
|
||||
"created": d.GetCreationTimestamp().UnixNano(),
|
||||
}
|
||||
tags := map[string]string{
|
||||
"deployment_name": d.Name,
|
||||
"namespace": d.Namespace,
|
||||
}
|
||||
for key, val := range d.Spec.Selector.MatchLabels {
|
||||
if ki.selectorFilter.Match(key) {
|
||||
tags["selector_"+key] = val
|
||||
}
|
||||
}
|
||||
|
||||
acc.AddFields(deploymentMeasurement, fields, tags)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue