Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cilium version metadata #5408

Merged
merged 4 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cilium/datadog_checks/cilium/cilium.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def __init__(self, name, init_config, instances):
'namespace': 'cilium',
'metrics': metrics,
'prometheus_timeout': instance.get('timeout', 10),
'metadata_metric_name': 'cilium_version',
'metadata_label_map': {'version': 'version'},
}
)

Expand Down
4 changes: 3 additions & 1 deletion cilium/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# (C) Datadog, Inc. 2019-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os

CHECK_NAME = 'cilium'
NAMESPACE = 'cilium.'

CILIUM_VERSION = os.getenv('CILIUM_VERSION')

AGENT_DEFAULT_METRICS = [
'cilium.agent.api_process_time.seconds.count',
Expand Down
3 changes: 3 additions & 0 deletions cilium/tests/fixtures/agent_metrics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1082,3 +1082,6 @@ cilium_unreachable_health_endpoints 0
# HELP cilium_unreachable_nodes Number of nodes that cannot be reached
# TYPE cilium_unreachable_nodes gauge
cilium_unreachable_nodes 1
# HELP cilium_version Cilium version
# TYPE cilium_version gauge
cilium_version{version="1.6.90"} 0
8 changes: 4 additions & 4 deletions cilium/tests/terraform/cilium.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ spec:
key: custom-cni-conf
name: cilium-config
optional: true
image: "docker.io/cilium/cilium:v1.6"
image: "docker.io/cilium/cilium:v1.6.5"
imagePullPolicy: IfNotPresent
lifecycle:
postStart:
Expand Down Expand Up @@ -449,7 +449,7 @@ spec:
initContainers:
- name: wait-for-node-init
command: ['sh', '-c', 'until stat /tmp/cilium-bootstrap-time > /dev/null 2>&1; do echo "Waiting on node-init to run..."; sleep 1; done']
image: "docker.io/cilium/cilium:v1.6"
image: "docker.io/cilium/cilium:v1.6.5"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /tmp/cilium-bootstrap-time
Expand All @@ -475,7 +475,7 @@ spec:
key: wait-bpf-mount
name: cilium-config
optional: true
image: "docker.io/cilium/cilium:v1.6"
image: "docker.io/cilium/cilium:v1.6.5"
imagePullPolicy: IfNotPresent
name: clean-cilium-state
securityContext:
Expand Down Expand Up @@ -757,7 +757,7 @@ spec:
key: identity-allocation-mode
name: cilium-config
optional: true
image: "docker.io/cilium/operator:v1.6"
image: "docker.io/cilium/operator:v1.6.5"
imagePullPolicy: IfNotPresent
name: cilium-operator
livenessProbe:
Expand Down
19 changes: 18 additions & 1 deletion cilium/tests/test_cilium.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
from datadog_checks.cilium import CiliumCheck

from .common import ADDL_AGENT_METRICS, AGENT_DEFAULT_METRICS, OPERATOR_AWS_METRICS, OPERATOR_METRICS
from .common import ADDL_AGENT_METRICS, AGENT_DEFAULT_METRICS, CILIUM_VERSION, OPERATOR_AWS_METRICS, OPERATOR_METRICS


def test_agent_check(aggregator, agent_instance, mock_agent_data):
Expand All @@ -22,3 +22,20 @@ def test_operator_check(aggregator, operator_instance, mock_operator_data):
for m in OPERATOR_METRICS + OPERATOR_AWS_METRICS:
aggregator.assert_metric(m)
aggregator.assert_all_metrics_covered()


def test_version_metadata(datadog_agent, agent_instance, mock_agent_data):
check = CiliumCheck('cilium', {}, [agent_instance])
check.check_id = 'test:123'
check.check(agent_instance)

major, minor, patch = CILIUM_VERSION.split('.')
version_metadata = {
'version.scheme': 'semver',
'version.major': major,
'version.minor': minor,
'version.patch': patch,
'version.raw': CILIUM_VERSION,
}

datadog_agent.assert_metadata('test:123', version_metadata)
2 changes: 2 additions & 0 deletions cilium/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ passenv =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
CILIUM_VERSION = 1.6.90