From 3be3b3464cab59cfb53da12e8f0691cc57e8e106 Mon Sep 17 00:00:00 2001 From: Stephan Feurer Date: Wed, 7 Aug 2024 08:44:49 +0200 Subject: [PATCH] Support creating LogFileMetricsExporter CR In logging version 5.8 and newer versions, the LogFileMetricExporter is no longer deployed with the collector by default. You must manually create a LogFileMetricExporter custom resource (CR) to generate metrics from the logs produced by running containers. If you do not create the LogFileMetricExporter CR, you may see a No datapoints found message in the OpenShift Container Platform web console dashboard for Produced Logs. --- class/defaults.yml | 12 ++++++++++++ component/logmetrics.libsonnet | 16 ++++++++++++++++ component/main.jsonnet | 1 + .../70_logmetricsexporter.yaml | 18 ++++++++++++++++++ .../70_logmetricsexporter.yaml | 18 ++++++++++++++++++ .../70_logmetricsexporter.yaml | 18 ++++++++++++++++++ .../70_logmetricsexporter.yaml | 18 ++++++++++++++++++ .../70_logmetricsexporter.yaml | 18 ++++++++++++++++++ 8 files changed, 119 insertions(+) create mode 100644 component/logmetrics.libsonnet create mode 100644 tests/golden/defaults/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml create mode 100644 tests/golden/elasticsearch/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml create mode 100644 tests/golden/forwardingonly/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml create mode 100644 tests/golden/master/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml create mode 100644 tests/golden/multilineerr/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml diff --git a/class/defaults.yml b/class/defaults.yml index a6a8abd..f936f9c 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -57,6 +57,18 @@ parameters: threshold: 85 for: 6h severity: warning + logmetrics: + enabled: true + spec: + nodeSelector: + node-role.kubernetes.io/infra: '' + resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 200m + memory: 128Mi clusterLogging: {} diff --git a/component/logmetrics.libsonnet b/component/logmetrics.libsonnet new file mode 100644 index 0000000..784d40e --- /dev/null +++ b/component/logmetrics.libsonnet @@ -0,0 +1,16 @@ +local kap = import 'lib/kapitan.libjsonnet'; +local kube = import 'lib/kube.libjsonnet'; + +local inv = kap.inventory(); +local params = inv.parameters.openshift4_logging; + +local logMetricExporter = kube._Object('logging.openshift.io/v1alpha1', 'LogFileMetricExporter', 'instance') { + metadata+: { + namespace: params.namespace, + }, + spec: params.components.logmetrics.spec, +}; + +{ + '70_logmetricsexporter': logMetricExporter, +} diff --git a/component/main.jsonnet b/component/main.jsonnet index 0e3a526..54ee15c 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -95,3 +95,4 @@ local subscriptions = std.filter(function(it) it != null, [ + (import 'loki.libsonnet') + (import 'elasticsearch.libsonnet') + (import 'alertrules.libsonnet') ++ (import 'logmetrics.libsonnet') diff --git a/tests/golden/defaults/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml b/tests/golden/defaults/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml new file mode 100644 index 0000000..0093d8d --- /dev/null +++ b/tests/golden/defaults/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml @@ -0,0 +1,18 @@ +apiVersion: logging.openshift.io/v1alpha1 +kind: LogFileMetricExporter +metadata: + annotations: {} + labels: + name: instance + name: instance + namespace: openshift-logging +spec: + nodeSelector: + node-role.kubernetes.io/infra: '' + resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 200m + memory: 128Mi diff --git a/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml b/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml new file mode 100644 index 0000000..0093d8d --- /dev/null +++ b/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml @@ -0,0 +1,18 @@ +apiVersion: logging.openshift.io/v1alpha1 +kind: LogFileMetricExporter +metadata: + annotations: {} + labels: + name: instance + name: instance + namespace: openshift-logging +spec: + nodeSelector: + node-role.kubernetes.io/infra: '' + resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 200m + memory: 128Mi diff --git a/tests/golden/forwardingonly/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml b/tests/golden/forwardingonly/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml new file mode 100644 index 0000000..0093d8d --- /dev/null +++ b/tests/golden/forwardingonly/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml @@ -0,0 +1,18 @@ +apiVersion: logging.openshift.io/v1alpha1 +kind: LogFileMetricExporter +metadata: + annotations: {} + labels: + name: instance + name: instance + namespace: openshift-logging +spec: + nodeSelector: + node-role.kubernetes.io/infra: '' + resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 200m + memory: 128Mi diff --git a/tests/golden/master/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml b/tests/golden/master/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml new file mode 100644 index 0000000..0093d8d --- /dev/null +++ b/tests/golden/master/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml @@ -0,0 +1,18 @@ +apiVersion: logging.openshift.io/v1alpha1 +kind: LogFileMetricExporter +metadata: + annotations: {} + labels: + name: instance + name: instance + namespace: openshift-logging +spec: + nodeSelector: + node-role.kubernetes.io/infra: '' + resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 200m + memory: 128Mi diff --git a/tests/golden/multilineerr/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml b/tests/golden/multilineerr/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml new file mode 100644 index 0000000..0093d8d --- /dev/null +++ b/tests/golden/multilineerr/openshift4-logging/openshift4-logging/70_logmetricsexporter.yaml @@ -0,0 +1,18 @@ +apiVersion: logging.openshift.io/v1alpha1 +kind: LogFileMetricExporter +metadata: + annotations: {} + labels: + name: instance + name: instance + namespace: openshift-logging +spec: + nodeSelector: + node-role.kubernetes.io/infra: '' + resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 200m + memory: 128Mi