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
61
plugins/inputs/kube_inventory/ingress.go
Normal file
61
plugins/inputs/kube_inventory/ingress.go
Normal file
|
@ -0,0 +1,61 @@
|
|||
package kube_inventory
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
netv1 "k8s.io/api/networking/v1"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
)
|
||||
|
||||
func collectIngress(ctx context.Context, acc telegraf.Accumulator, ki *KubernetesInventory) {
|
||||
list, err := ki.client.getIngress(ctx)
|
||||
if err != nil {
|
||||
acc.AddError(err)
|
||||
return
|
||||
}
|
||||
for _, i := range list.Items {
|
||||
gatherIngress(i, acc)
|
||||
}
|
||||
}
|
||||
|
||||
func gatherIngress(i netv1.Ingress, acc telegraf.Accumulator) {
|
||||
creationTS := i.GetCreationTimestamp()
|
||||
if creationTS.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
fields := map[string]interface{}{
|
||||
"created": i.GetCreationTimestamp().UnixNano(),
|
||||
"generation": i.Generation,
|
||||
}
|
||||
|
||||
tags := map[string]string{
|
||||
"ingress_name": i.Name,
|
||||
"namespace": i.Namespace,
|
||||
}
|
||||
|
||||
for _, ingress := range i.Status.LoadBalancer.Ingress {
|
||||
tags["hostname"] = ingress.Hostname
|
||||
tags["ip"] = ingress.IP
|
||||
|
||||
for _, rule := range i.Spec.Rules {
|
||||
if rule.IngressRuleValue.HTTP == nil {
|
||||
continue
|
||||
}
|
||||
for _, path := range rule.IngressRuleValue.HTTP.Paths {
|
||||
if path.Backend.Service != nil {
|
||||
tags["backend_service_name"] = path.Backend.Service.Name
|
||||
fields["backend_service_port"] = path.Backend.Service.Port.Number
|
||||
}
|
||||
|
||||
fields["tls"] = i.Spec.TLS != nil
|
||||
|
||||
tags["path"] = path.Path
|
||||
tags["host"] = rule.Host
|
||||
|
||||
acc.AddFields(ingressMeasurement, fields, tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue