diff --git a/examples/eks-cni-example.jsonnet b/examples/eks-cni-example.jsonnet index 62c9170cd41278704759d9a2bd0f6e0331aa5c14..6c6780451c682f7fee76b22100c5bf6704862208 100644 --- a/examples/eks-cni-example.jsonnet +++ b/examples/eks-cni-example.jsonnet @@ -1,47 +1,19 @@ local kp = (import 'kube-prometheus/kube-prometheus-eks.libsonnet') + { - local service = kp.core.v1.service, - local servicePort = kp.core.v1.service.mixin.spec.portsType, _config+:: { namespace: 'monitoring', }, - prometheus+: { - AwsEksCniMetricService: - service.new('aws-node', { 'k8s-app' : 'aws-node' } , servicePort.newNamed('cni-metrics-port', 61678, 61678)) + - service.mixin.metadata.withNamespace('kube-system') + - service.mixin.metadata.withLabels({ 'k8s-app': 'aws-node' }) + - service.mixin.spec.withClusterIp('None'), - serviceMonitorAwsEksCNI: + prometheusRules+:: { + groups+: [ { - apiVersion: 'monitoring.coreos.com/v1', - kind: 'ServiceMonitor', - metadata: { - name: 'awsekscni', - namespace: kp.namespace, - labels: { - 'k8s-app': 'eks-cni', + name: 'example-group', + rules: [ + { + record: 'aws_eks_available_ip', + expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < 10', }, - }, - spec: { - jobLabel: 'k8s-app', - selector: { - matchLabels: { - 'k8s-app': 'aws-node', - }, - }, - namespaceSelector: { - matchNames: [ - 'kube-system', - ], - }, - endpoints: [ - { - port: 'cni-metrics-port', - interval: '30s', - path: '/metrics', - }, - ], - }, + ], }, + ], }, }; @@ -49,7 +21,5 @@ local kp = (import 'kube-prometheus/kube-prometheus-eks.libsonnet') + { { ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } + { ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + { ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } + -{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } + { ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + -{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } + -{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } diff --git a/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet b/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet index aa7495346bd702bf7efbf39fbff6292328fd166a..701d3c41e1188305eb2d61abbb4644964e61bed3 100644 --- a/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet +++ b/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet @@ -15,7 +15,7 @@ local servicePort = k.core.v1.service.mixin.spec.portsType; kind: 'ServiceMonitor', metadata: { name: 'awsekscni', - namespace: 'monitoring', + namespace: $._config.namespace, labels: { 'k8s-app': 'eks-cni', },