diff --git a/.chloggen/metric-index-from-annottaions.yaml b/.chloggen/metric-index-from-annottaions.yaml new file mode 100644 index 0000000000..ddc0484228 --- /dev/null +++ b/.chloggen/metric-index-from-annottaions.yaml @@ -0,0 +1,12 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement +# The name of the component, or a single word describing the area of concern, (e.g. agent, clusterReceiver, gateway, networkExplorer, operator, chart, other) +component: other +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Added support for rerouting metrics index with pod/namespace annotations +# One or more tracking issues related to the change +issues: [1053] +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/ci_scripts/k8s-splunk.yml b/ci_scripts/k8s-splunk.yml index 6084895399..3cd697ea5f 100644 --- a/ci_scripts/k8s-splunk.yml +++ b/ci_scripts/k8s-splunk.yml @@ -40,6 +40,12 @@ data: homePath: $SPLUNK_DB/pod-anno/db maxTotalDataSizeMB: 512000 thawedPath: $SPLUNK_DB/pod-anno/thaweddb + test_metrics: + coldPath: $SPLUNK_DB/test_metrics/colddb + datatype: metric + homePath: $SPLUNK_DB/test_metrics/db + maxTotalDataSizeMB: 512000 + thawedPath: $SPLUNK_DB/test_metrics/thaweddb --- apiVersion: v1 kind: Pod diff --git a/docs/advanced-configuration.md b/docs/advanced-configuration.md index b01344f1d1..2e621a04e3 100644 --- a/docs/advanced-configuration.md +++ b/docs/advanced-configuration.md @@ -559,6 +559,7 @@ Manage Splunk OTel Collector Logging with these supported annotations. * Use `splunk.com/index` annotation on pod and/or namespace to tell which Splunk platform indexes to ingest to. Pod annotation will take precedence over namespace annotation when both are annotated. For example, the following command will make logs from `kube-system` namespace to be sent to `k8s_events` index: `kubectl annotate namespace kube-system splunk.com/index=k8s_events` +* Use `splunk.com/metricsIndex` annotation on pod and/or namespace to tell which Splunk platform metric indexes to ingest to. Pod annotation will take precedence over namespace annotation when both are annotated. * Filter logs using pod and/or namespace annotation * If `logsCollection.containers.useSplunkIncludeAnnotation` is `false` (default: false), set `splunk.com/exclude` annotation to `true` on pod and/or namespace to exclude its logs from ingested. * If `logsCollection.containers.useSplunkIncludeAnnotation` is `true` (default: false), set `splunk.com/include` annotation to `true` on pod and/or namespace to only include its logs from ingested. All other logs will be ignored. diff --git a/examples/disable-persistence-queue-traces/rendered_manifests/configmap-agent.yaml b/examples/disable-persistence-queue-traces/rendered_manifests/configmap-agent.yaml index 919aa03ca8..4994574952 100644 --- a/examples/disable-persistence-queue-traces/rendered_manifests/configmap-agent.yaml +++ b/examples/disable-persistence-queue-traces/rendered_manifests/configmap-agent.yaml @@ -156,6 +156,35 @@ data: - sources: - from: resource_attribute name: host.name + k8sattributes/metrics: + extract: + annotations: + - from: pod + key: splunk.com/sourcetype + - from: namespace + key: splunk.com/metricsIndex + tag_name: com.splunk.index + - from: pod + key: splunk.com/metricsIndex + tag_name: com.splunk.index + metadata: [] + filter: + node_from_env_var: K8S_NODE_NAME + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection memory_limiter: check_interval: 2s limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB} @@ -429,6 +458,7 @@ data: - batch - resourcedetection - resource + - k8sattributes/metrics receivers: - hostmetrics - kubeletstats @@ -444,6 +474,7 @@ data: - resource/add_agent_k8s - resourcedetection - resource + - k8sattributes/metrics receivers: - prometheus/agent traces: diff --git a/examples/disable-persistence-queue-traces/rendered_manifests/configmap-cluster-receiver.yaml b/examples/disable-persistence-queue-traces/rendered_manifests/configmap-cluster-receiver.yaml index 3252c0b175..e8a70f204b 100644 --- a/examples/disable-persistence-queue-traces/rendered_manifests/configmap-cluster-receiver.yaml +++ b/examples/disable-persistence-queue-traces/rendered_manifests/configmap-cluster-receiver.yaml @@ -47,6 +47,35 @@ data: processors: batch: send_batch_max_size: 32768 + k8sattributes/metrics: + extract: + annotations: + - from: pod + key: splunk.com/sourcetype + - from: namespace + key: splunk.com/metricsIndex + tag_name: com.splunk.index + - from: pod + key: splunk.com/metricsIndex + tag_name: com.splunk.index + metadata: [] + filter: + node_from_env_var: K8S_NODE_NAME + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection memory_limiter: check_interval: 2s limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB} @@ -106,6 +135,7 @@ data: - memory_limiter - batch - resource + - k8sattributes/metrics - resource/k8s_cluster receivers: - k8s_cluster @@ -118,6 +148,7 @@ data: - resource/add_collector_k8s - resourcedetection - resource + - k8sattributes/metrics receivers: - prometheus/k8s_cluster_receiver telemetry: diff --git a/examples/disable-persistence-queue-traces/rendered_manifests/daemonset.yaml b/examples/disable-persistence-queue-traces/rendered_manifests/daemonset.yaml index 71d0c19514..b60e8501ac 100644 --- a/examples/disable-persistence-queue-traces/rendered_manifests/daemonset.yaml +++ b/examples/disable-persistence-queue-traces/rendered_manifests/daemonset.yaml @@ -31,7 +31,7 @@ spec: component: otel-collector-agent release: default annotations: - checksum/config: 1e403a41cc6f461fdb2e6cdbb8b9f6cbbac9f1ef9d9def2b9a1b19e51a4edad7 + checksum/config: 1ac6bb159cb4e899265ef7db4a8bb1dde9f62446df6e6b16995bcf7d212e09f2 kubectl.kubernetes.io/default-container: otel-collector spec: hostNetwork: true diff --git a/examples/disable-persistence-queue-traces/rendered_manifests/deployment-cluster-receiver.yaml b/examples/disable-persistence-queue-traces/rendered_manifests/deployment-cluster-receiver.yaml index d3964c0811..9d0f9778c3 100644 --- a/examples/disable-persistence-queue-traces/rendered_manifests/deployment-cluster-receiver.yaml +++ b/examples/disable-persistence-queue-traces/rendered_manifests/deployment-cluster-receiver.yaml @@ -30,7 +30,7 @@ spec: component: otel-k8s-cluster-receiver release: default annotations: - checksum/config: c96290e06409602ae77ddb5b867ab2c00d568da4a31fda5ee5e8f0cbbff5a760 + checksum/config: 2014df4d79530856fc4c52d10df0cbee831f67b794e53081e3569d1970af9943 spec: serviceAccountName: default-splunk-otel-collector nodeSelector: diff --git a/examples/enable-persistence-queue/rendered_manifests/configmap-agent.yaml b/examples/enable-persistence-queue/rendered_manifests/configmap-agent.yaml index 0a8278c564..b3d8e68348 100644 --- a/examples/enable-persistence-queue/rendered_manifests/configmap-agent.yaml +++ b/examples/enable-persistence-queue/rendered_manifests/configmap-agent.yaml @@ -156,6 +156,35 @@ data: - sources: - from: resource_attribute name: host.name + k8sattributes/metrics: + extract: + annotations: + - from: pod + key: splunk.com/sourcetype + - from: namespace + key: splunk.com/metricsIndex + tag_name: com.splunk.index + - from: pod + key: splunk.com/metricsIndex + tag_name: com.splunk.index + metadata: [] + filter: + node_from_env_var: K8S_NODE_NAME + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection memory_limiter: check_interval: 2s limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB} @@ -429,6 +458,7 @@ data: - batch - resourcedetection - resource + - k8sattributes/metrics receivers: - hostmetrics - kubeletstats @@ -444,6 +474,7 @@ data: - resource/add_agent_k8s - resourcedetection - resource + - k8sattributes/metrics receivers: - prometheus/agent traces: diff --git a/examples/enable-persistence-queue/rendered_manifests/configmap-cluster-receiver.yaml b/examples/enable-persistence-queue/rendered_manifests/configmap-cluster-receiver.yaml index 3252c0b175..e8a70f204b 100644 --- a/examples/enable-persistence-queue/rendered_manifests/configmap-cluster-receiver.yaml +++ b/examples/enable-persistence-queue/rendered_manifests/configmap-cluster-receiver.yaml @@ -47,6 +47,35 @@ data: processors: batch: send_batch_max_size: 32768 + k8sattributes/metrics: + extract: + annotations: + - from: pod + key: splunk.com/sourcetype + - from: namespace + key: splunk.com/metricsIndex + tag_name: com.splunk.index + - from: pod + key: splunk.com/metricsIndex + tag_name: com.splunk.index + metadata: [] + filter: + node_from_env_var: K8S_NODE_NAME + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection memory_limiter: check_interval: 2s limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB} @@ -106,6 +135,7 @@ data: - memory_limiter - batch - resource + - k8sattributes/metrics - resource/k8s_cluster receivers: - k8s_cluster @@ -118,6 +148,7 @@ data: - resource/add_collector_k8s - resourcedetection - resource + - k8sattributes/metrics receivers: - prometheus/k8s_cluster_receiver telemetry: diff --git a/examples/enable-persistence-queue/rendered_manifests/daemonset.yaml b/examples/enable-persistence-queue/rendered_manifests/daemonset.yaml index 4a04e762e4..4afe9a4047 100644 --- a/examples/enable-persistence-queue/rendered_manifests/daemonset.yaml +++ b/examples/enable-persistence-queue/rendered_manifests/daemonset.yaml @@ -31,7 +31,7 @@ spec: component: otel-collector-agent release: default annotations: - checksum/config: 1ac2acf8252d8317c6ada3aacf85bbf865dc2d340336e3c7dec8af277002e3af + checksum/config: 005a69103acb8660014c49e7c37407fda7dd1d2a464dc4faa68d53c3587849be kubectl.kubernetes.io/default-container: otel-collector spec: hostNetwork: true diff --git a/examples/enable-persistence-queue/rendered_manifests/deployment-cluster-receiver.yaml b/examples/enable-persistence-queue/rendered_manifests/deployment-cluster-receiver.yaml index d3964c0811..9d0f9778c3 100644 --- a/examples/enable-persistence-queue/rendered_manifests/deployment-cluster-receiver.yaml +++ b/examples/enable-persistence-queue/rendered_manifests/deployment-cluster-receiver.yaml @@ -30,7 +30,7 @@ spec: component: otel-k8s-cluster-receiver release: default annotations: - checksum/config: c96290e06409602ae77ddb5b867ab2c00d568da4a31fda5ee5e8f0cbbff5a760 + checksum/config: 2014df4d79530856fc4c52d10df0cbee831f67b794e53081e3569d1970af9943 spec: serviceAccountName: default-splunk-otel-collector nodeSelector: diff --git a/examples/only-metrics-platform/rendered_manifests/configmap-agent.yaml b/examples/only-metrics-platform/rendered_manifests/configmap-agent.yaml index 101236c050..40326c8adf 100644 --- a/examples/only-metrics-platform/rendered_manifests/configmap-agent.yaml +++ b/examples/only-metrics-platform/rendered_manifests/configmap-agent.yaml @@ -101,6 +101,35 @@ data: - sources: - from: resource_attribute name: host.name + k8sattributes/metrics: + extract: + annotations: + - from: pod + key: splunk.com/sourcetype + - from: namespace + key: splunk.com/metricsIndex + tag_name: com.splunk.index + - from: pod + key: splunk.com/metricsIndex + tag_name: com.splunk.index + metadata: [] + filter: + node_from_env_var: K8S_NODE_NAME + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection memory_limiter: check_interval: 2s limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB} @@ -239,6 +268,7 @@ data: - batch - resourcedetection - resource + - k8sattributes/metrics receivers: - hostmetrics - kubeletstats @@ -254,6 +284,7 @@ data: - resource/add_agent_k8s - resourcedetection - resource + - k8sattributes/metrics receivers: - prometheus/agent telemetry: diff --git a/examples/only-metrics-platform/rendered_manifests/configmap-cluster-receiver.yaml b/examples/only-metrics-platform/rendered_manifests/configmap-cluster-receiver.yaml index 3252c0b175..e8a70f204b 100644 --- a/examples/only-metrics-platform/rendered_manifests/configmap-cluster-receiver.yaml +++ b/examples/only-metrics-platform/rendered_manifests/configmap-cluster-receiver.yaml @@ -47,6 +47,35 @@ data: processors: batch: send_batch_max_size: 32768 + k8sattributes/metrics: + extract: + annotations: + - from: pod + key: splunk.com/sourcetype + - from: namespace + key: splunk.com/metricsIndex + tag_name: com.splunk.index + - from: pod + key: splunk.com/metricsIndex + tag_name: com.splunk.index + metadata: [] + filter: + node_from_env_var: K8S_NODE_NAME + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection memory_limiter: check_interval: 2s limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB} @@ -106,6 +135,7 @@ data: - memory_limiter - batch - resource + - k8sattributes/metrics - resource/k8s_cluster receivers: - k8s_cluster @@ -118,6 +148,7 @@ data: - resource/add_collector_k8s - resourcedetection - resource + - k8sattributes/metrics receivers: - prometheus/k8s_cluster_receiver telemetry: diff --git a/examples/only-metrics-platform/rendered_manifests/daemonset.yaml b/examples/only-metrics-platform/rendered_manifests/daemonset.yaml index b586a80129..041cfbcefa 100644 --- a/examples/only-metrics-platform/rendered_manifests/daemonset.yaml +++ b/examples/only-metrics-platform/rendered_manifests/daemonset.yaml @@ -31,7 +31,7 @@ spec: component: otel-collector-agent release: default annotations: - checksum/config: 885ac89d11ea4495aaaa8cceff3f3251814e43e145a72063ab38c45e47bd8dfc + checksum/config: 11b7dc56fc2e8bb7707daea4f680cdcc59af58cb61bcea3e2c433834767e6a04 kubectl.kubernetes.io/default-container: otel-collector spec: hostNetwork: true diff --git a/examples/only-metrics-platform/rendered_manifests/deployment-cluster-receiver.yaml b/examples/only-metrics-platform/rendered_manifests/deployment-cluster-receiver.yaml index d3964c0811..9d0f9778c3 100644 --- a/examples/only-metrics-platform/rendered_manifests/deployment-cluster-receiver.yaml +++ b/examples/only-metrics-platform/rendered_manifests/deployment-cluster-receiver.yaml @@ -30,7 +30,7 @@ spec: component: otel-k8s-cluster-receiver release: default annotations: - checksum/config: c96290e06409602ae77ddb5b867ab2c00d568da4a31fda5ee5e8f0cbbff5a760 + checksum/config: 2014df4d79530856fc4c52d10df0cbee831f67b794e53081e3569d1970af9943 spec: serviceAccountName: default-splunk-otel-collector nodeSelector: diff --git a/helm-charts/splunk-otel-collector/templates/config/_common.tpl b/helm-charts/splunk-otel-collector/templates/config/_common.tpl index b6f3410e4a..d7698ab5c7 100644 --- a/helm-charts/splunk-otel-collector/templates/config/_common.tpl +++ b/helm-charts/splunk-otel-collector/templates/config/_common.tpl @@ -211,6 +211,39 @@ k8sattributes: {{- end }} {{- end }} +{{/* +Common config for K8s attributes processor adding k8s metadata to metrics resource attributes. +*/}} +{{- define "splunk-otel-collector.k8sAttributesSplunkPlatformMetrics" -}} +k8sattributes/metrics: + pod_association: + - sources: + - from: resource_attribute + name: k8s.node.name + - sources: + - from: resource_attribute + name: k8s.pod.uid + - sources: + - from: resource_attribute + name: k8s.pod.ip + - sources: + - from: resource_attribute + name: ip + - sources: + - from: connection + extract: + metadata: [] + annotations: + - key: splunk.com/sourcetype + from: pod + - key: splunk.com/metricsIndex + tag_name: com.splunk.index + from: namespace + - key: splunk.com/metricsIndex + tag_name: com.splunk.index + from: pod +{{- end }} + {{/* Resource processor for logs manipulations */}} diff --git a/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl b/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl index 3099bc08f4..8f5058bde0 100644 --- a/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl +++ b/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl @@ -484,6 +484,13 @@ processors: filter: node_from_env_var: K8S_NODE_NAME + + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + {{- include "splunk-otel-collector.k8sAttributesSplunkPlatformMetrics" . | nindent 2 }} + filter: + node_from_env_var: K8S_NODE_NAME + {{- end }} + {{- if eq .Values.logsEngine "fluentd" }} # Move flat fluentd logs attributes to resource attributes groupbyattrs/logs: @@ -824,6 +831,9 @@ service: {{- if .Values.isWindows }} - metricstransform {{- end }} + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} exporters: {{- if $gatewayEnabled }} - otlp @@ -847,6 +857,9 @@ service: - resource/add_agent_k8s - resourcedetection - resource + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} exporters: {{- if (eq (include "splunk-otel-collector.splunkO11yEnabled" .) "true") }} # Use signalfx instead of otlp even if collector is enabled diff --git a/helm-charts/splunk-otel-collector/templates/config/_otel-collector.tpl b/helm-charts/splunk-otel-collector/templates/config/_otel-collector.tpl index ac746ea5ab..18c90f09b6 100644 --- a/helm-charts/splunk-otel-collector/templates/config/_otel-collector.tpl +++ b/helm-charts/splunk-otel-collector/templates/config/_otel-collector.tpl @@ -34,6 +34,13 @@ receivers: # By default k8sattributes, memory_limiter and batch processors enabled. processors: {{- include "splunk-otel-collector.k8sAttributesProcessor" . | nindent 2 }} + + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + {{- include "splunk-otel-collector.k8sAttributesSplunkPlatformMetrics" . | nindent 2 }} + filter: + node_from_env_var: K8S_NODE_NAME + {{- end }} + {{- include "splunk-otel-collector.resourceLogsProcessor" . | nindent 2 }} {{- if .Values.autodetect.istio }} {{- include "splunk-otel-collector.transformLogsProcessor" . | nindent 2 }} @@ -198,6 +205,9 @@ service: {{- if (and .Values.splunkPlatform.metricsEnabled .Values.environment) }} - resource/add_environment {{- end }} + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} exporters: {{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }} - signalfx @@ -249,6 +259,9 @@ service: {{- if .Values.clusterName }} - resource/add_cluster_name {{- end }} + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} exporters: {{- if (eq (include "splunk-otel-collector.splunkO11yEnabled" .) "true") }} - signalfx diff --git a/helm-charts/splunk-otel-collector/templates/config/_otel-k8s-cluster-receiver-config.tpl b/helm-charts/splunk-otel-collector/templates/config/_otel-k8s-cluster-receiver-config.tpl index 9d9e245e5a..6476280196 100644 --- a/helm-charts/splunk-otel-collector/templates/config/_otel-k8s-cluster-receiver-config.tpl +++ b/helm-charts/splunk-otel-collector/templates/config/_otel-k8s-cluster-receiver-config.tpl @@ -82,6 +82,12 @@ receivers: processors: {{- include "splunk-otel-collector.otelMemoryLimiterConfig" . | nindent 2 }} + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + {{- include "splunk-otel-collector.k8sAttributesSplunkPlatformMetrics" . | nindent 2 }} + filter: + node_from_env_var: K8S_NODE_NAME + {{- end }} + batch: send_batch_max_size: 32768 @@ -221,6 +227,9 @@ service: - resourcedetection/k8s_cluster_name {{- end }} - resource + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} - resource/k8s_cluster exporters: {{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }} @@ -240,6 +249,9 @@ service: - resourcedetection/k8s_cluster_name {{- end }} - resource + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} exporters: {{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }} - signalfx @@ -258,6 +270,9 @@ service: - resource/add_collector_k8s - resourcedetection - resource + {{- if (eq (include "splunk-otel-collector.platformMetricsEnabled" $) "true") }} + - k8sattributes/metrics + {{- end }} exporters: {{- if (eq (include "splunk-otel-collector.o11yMetricsEnabled" .) "true") }} - signalfx diff --git a/test/k8s_logging_tests/test_config_logging.py b/test/k8s_logging_tests/test_config_logging.py index 8302c0424e..c062038ff7 100644 --- a/test/k8s_logging_tests/test_config_logging.py +++ b/test/k8s_logging_tests/test_config_logging.py @@ -130,3 +130,24 @@ def test_journald_unit(setup, test_input, expected): len(events)) assert len(events) >= expected if test_input != "empty_unit" else len( events) == expected + +@pytest.mark.parametrize("index,expected", [ + ("test_metrics", 1) +]) +def test_metric_index_from_annotations(setup, index, expected): + + ''' + Test that metrics are being sent to "test_metrics" index, as defined by splunk.com/metricsIndex annotation added during setup + ''' + logger.info("testing for metrics index={0} expected={1} event(s)".format(index, expected)) + search_query = "index=" + index + + events = check_events_from_splunk(start_time="-1h@h", + url=setup["splunkd_url"], + user=setup["splunk_user"], + query=["mpreview {0}".format( + search_query)], + password=setup["splunk_password"]) + logger.info("Splunk received %s events in the last minute", + len(events)) + assert len(events) >= expected diff --git a/test/test_setup.yaml b/test/test_setup.yaml index 7cebba094d..82434fa2d4 100644 --- a/test/test_setup.yaml +++ b/test/test_setup.yaml @@ -20,6 +20,13 @@ metadata: splunk.com/index: ns-anno splunk.com/exclude: "true" --- +apiVersion: v1 +kind: Namespace +metadata: + name: default + annotations: + splunk.com/metricsIndex: test_metrics +--- apiVersion: batch/v1 kind: Job metadata: