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
49
plugins/inputs/kube_inventory/statefulset.go
Normal file
49
plugins/inputs/kube_inventory/statefulset.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package kube_inventory
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"k8s.io/api/apps/v1"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
)
|
||||
|
||||
func collectStatefulSets(ctx context.Context, acc telegraf.Accumulator, ki *KubernetesInventory) {
|
||||
list, err := ki.client.getStatefulSets(ctx)
|
||||
if err != nil {
|
||||
acc.AddError(err)
|
||||
return
|
||||
}
|
||||
for i := range list.Items {
|
||||
ki.gatherStatefulSet(&list.Items[i], acc)
|
||||
}
|
||||
}
|
||||
|
||||
func (ki *KubernetesInventory) gatherStatefulSet(s *v1.StatefulSet, acc telegraf.Accumulator) {
|
||||
status := s.Status
|
||||
fields := map[string]interface{}{
|
||||
"created": s.GetCreationTimestamp().UnixNano(),
|
||||
"generation": s.Generation,
|
||||
"replicas": status.Replicas,
|
||||
"replicas_current": status.CurrentReplicas,
|
||||
"replicas_ready": status.ReadyReplicas,
|
||||
"replicas_updated": status.UpdatedReplicas,
|
||||
"observed_generation": s.Status.ObservedGeneration,
|
||||
}
|
||||
if s.Spec.Replicas != nil {
|
||||
fields["spec_replicas"] = *s.Spec.Replicas
|
||||
}
|
||||
tags := map[string]string{
|
||||
"statefulset_name": s.Name,
|
||||
"namespace": s.Namespace,
|
||||
}
|
||||
if s.Spec.Selector != nil {
|
||||
for key, val := range s.Spec.Selector.MatchLabels {
|
||||
if ki.selectorFilter.Match(key) {
|
||||
tags["selector_"+key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
acc.AddFields(statefulSetMeasurement, fields, tags)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue