diff --git a/.chloggen/2995-openshift-dashboard.yaml b/.chloggen/2995-openshift-dashboard.yaml new file mode 100755 index 0000000000..2c7305ca94 --- /dev/null +++ b/.chloggen/2995-openshift-dashboard.yaml @@ -0,0 +1,16 @@ +# 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. collector, target allocator, auto-instrumentation, opamp, github action) +component: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Create automatically an OpenShift dashboard to visualize OpenTelemetry Collector metrics + +# One or more tracking issues related to the change +issues: [2995] + +# (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: To enable this feature, you need to specify the `--create-openshift-dashboard` argument to the operator diff --git a/internal/openshift/dashboards/dashboards.go b/internal/openshift/dashboards/dashboards.go new file mode 100644 index 0000000000..99c03f2c8a --- /dev/null +++ b/internal/openshift/dashboards/dashboards.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package openshift + +import ( + "context" + _ "embed" + + "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" +) + +//go:embed metrics-dashboard.json +var dashboardContent string + +const ( + openshiftDashboardsNamespace = "openshift-config-managed" + configMapName = "opentelemetry-collector" +) + +func CreateOpenShiftDashboard(clientset kubernetes.Interface) error { + cm := corev1.ConfigMap{ + ObjectMeta: v1.ObjectMeta{ + Name: configMapName, + Namespace: openshiftDashboardsNamespace, + Labels: map[string]string{ + "console.openshift.io/dashboard": "true", + }, + }, + Data: map[string]string{ + "otel.json": dashboardContent, + }, + } + + _, err := clientset.CoreV1().ConfigMaps(openshiftDashboardsNamespace).Create(context.TODO(), &cm, metav1.CreateOptions{}) + return err +} + +func DeleteOpenShiftDashboard(clientset kubernetes.Interface, logger logr.Logger) { + err := clientset.CoreV1().ConfigMaps(openshiftDashboardsNamespace).Delete(context.TODO(), configMapName, metav1.DeleteOptions{}) + if err != nil { + logger.Error(err, "it was not possible to remove the dashboards configmap", "name", configMapName, "namespace", openshiftDashboardsNamespace) + } +} diff --git a/internal/openshift/dashboards/metrics-dashboard.json b/internal/openshift/dashboards/metrics-dashboard.json new file mode 100644 index 0000000000..49a83f9513 --- /dev/null +++ b/internal/openshift/dashboards/metrics-dashboard.json @@ -0,0 +1,1175 @@ +{ + "annotations": { + "list": [ + { + "$$hashKey": "object:517", + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Provides information about the status of the OpenTelemetry Collector", + "editable": true, + "gnetId": 12553, + "graphTooltip": 0, + "id": 1, + "iteration": 1709054947987, + "links": [], + "rows": [ + { + "collapse": false, + "height": "250px", + "panels": [ + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 12, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "rate(otelcol_receiver_accepted_metric_points{receiver=~\"$metric receiver\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{receiver}}/{{service_name}}/{{namespace}} accepted/sec", + "refId": "A" + }, + { + "expr": "rate(otelcol_receiver_refused_metric_points{receiver=~\"$metric receiver\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{ receiver }}/{{service_name}}/{{namespace}} refused/ sec", + "refId": "B" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Metrics Accepted vs Refused Received / second", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 13, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "rate(otelcol_exporter_sent_metric_points{exporter=~\"$metric exporter\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{exporter}}/{{service_name}}/{{namespace}} sent/sec", + "refId": "A" + }, + { + "expr": "rate(otelcol_exporter_send_failed_metric_points{exporter=~\"$metric exporter\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{ exporter }}/{{service_name}}/{{namespace}} failed/sec", + "refId": "B" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Metrics Exported vs Failed / second", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 13, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "rate(otelcol_processor_accepted_metric_points{processor=~\"$metric processor\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{processor}} | accepted", + "refId": "A" + }, + { + "expr": "rate(otelcol_processor_dropped_metric_points{processor=~\"$metric processor\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{processor}}/{{service_name}}/{{namespace}} | dropped", + "refId": "B" + }, + { + "expr": "rate(otelcol_processor_refused_metric_points{processor=~\"$metric processor\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{processor}}/{{service_name}}/{{namespace}} | refused", + "refId": "C" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Processor Metrics accepted, dropped, refused / second", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": true, + "title": "Metrics", + "titleSize": "h6" + }, + + { + "collapse": false, + "height": "250px", + "panels": [ + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 12, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "rate(otelcol_receiver_accepted_spans{receiver=~\"$span receiver\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{receiver}}/{{service_name}}/{{namespace}} accepted/sec", + "refId": "A" + }, + { + "expr": "rate(otelcol_receiver_refused_spans{receiver=~\"$span receiver\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{ receiver }}/{{service_name}}/{{namespace}} refused/sec", + "refId": "B" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Spans Accepted vs Refused Received / second", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 13, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "rate(otelcol_exporter_sent_spans{exporter=~\"$span exporter\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{exporter}}/{{service_name}}/{{namespace}} sent/sec", + "refId": "A" + }, + { + "expr": "rate(otelcol_exporter_send_failed_spans{exporter=~\"$span exporter\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{ exporter }}/{{service_name}}/{{namespace}} failed/sec", + "refId": "B" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Spans Exported vs Failed / second", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 13, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "rate(otelcol_processor_accepted_spans{processor=~\"$span processor\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{processor}}/{{service_name}}/{{namespace}} | accepted", + "refId": "A" + }, + { + "expr": "rate(otelcol_processor_dropped_spans{processor=~\"$span processor\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{processor}}/{{service_name}}/{{namespace}} | dropped", + "refId": "B" + }, + { + "expr": "rate(otelcol_processor_refused_spans{processor=~\"$span processor\",namespace=~\"$namespace\",service_name=~\"$collector instance\"}[1m])", + "interval": "", + "legendFormat": "{{processor}}/{{service_name}}/{{namespace}} | refused", + "refId": "C" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Processor Spans accepted, dropped, refused / second", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": true, + "title": "Traces", + "titleSize": "h6" + }, + + { + "collapse": false, + "height": "250px", + "panels": [ + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 12, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + + { + "editorMode": "code", + "exemplar": true, + "expr": "otelcol_process_memory_rss{service_name=~\"$collector instance\",namespace=~\"$namespace\"}", + "format": "time_series", + "hide": false, + "interval": "$minstep", + "intervalFactor": 1, + "legendFormat": "{{service_name}}/{{namespace}}", + "range": true, + "refId": "C" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Total physical memory (resident set size)", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 12, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "otelcol_process_runtime_heap_alloc_bytes{service_name=~\"$collector instance\",namespace=~\"$namespace\"}", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{service_name}}/{{namespace}}", + "refId": "A" + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Bytes of allocated heap objects", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + }, + { + "aliasColors": { + + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 12, + "interval": "1m", + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ + + ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + + ], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + + "editorMode": "code", + "exemplar": true, + "expr": "rate(otelcol_process_cpu_seconds{service_name=~\"$collector instance\",namespace=~\"$namespace\"}[1m])*100", + "format": "time_series", + "hide": false, + "interval": "$minstep", + "intervalFactor": 1, + "legendFormat": "CPU usage {{service_name}}/{{namespace}}", + "range": true + } + ], + "thresholds": [ + + ], + "timeFrom": null, + "timeShift": null, + "title": "Total CPU user and system time in percentage", + "tooltip": { + "shared": false, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ + + ] + }, + "yaxes": [ + { + "format": "%", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": true, + "title": "Resource usage", + "titleSize": "h6" + } + ], + "refresh": false, + "schemaVersion": 22, + "style": "dark", + "tags": [ + "opentelemetry" + ], + "templating": { + "list": [ + { + "current": { + "text": "Prometheus", + "value": "Prometheus" + }, + "hide": 0, + "label": "Data Source", + "name": "datasource", + "options": [ + + ], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "span exporter", + "options": [], + "query": "label_values(otelcol_exporter_sent_spans, exporter)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "metric receiver", + "options": [], + "query": "label_values(otelcol_receiver_accepted_metric_points, receiver)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "metric exporter", + "options": [], + "query": "label_values(otelcol_exporter_send_failed_metric_points, exporter)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "span receiver", + "options": [], + "query": "label_values(otelcol_receiver_accepted_spans, receiver)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "span processor", + "options": [], + "query": "label_values(otelcol_processor_accepted_spans, processor)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "metric processor", + "options": [], + "query": "label_values(otelcol_processor_accepted_metric_points, processor)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".+", + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "text": "kube-system", + "value": "kube-system" + }, + "datasource": "$datasource", + "definition": "label_values(container_network_receive_packets_total, namespace)", + "hide": 0, + "includeAll": true, + "label": null, + "multi": false, + "name": "namespace", + "options": [ + + ], + "query": "label_values(container_network_receive_packets_total, namespace)", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [ + + ], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "multi": true, + "name": "collector instance", + "options": [], + "query": "label_values(target_info, service_name)", + "refresh": 2, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "2024-02-27T17:13:44.201Z", + "to": "2024-02-27T17:43:44.201Z" + }, + "timepicker": { + "refresh_intervals": [ + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "OpenTelemetry Collector", + "uid": "BKf2sowmj", + "variables": { + "list": [] + }, + "version": 2 +} \ No newline at end of file diff --git a/main.go b/main.go index 520e1f1f5a..c62745fe97 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/openshift" "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/prometheus" "github.com/open-telemetry/opentelemetry-operator/internal/config" + openshiftDashboards "github.com/open-telemetry/opentelemetry-operator/internal/openshift/dashboards" "github.com/open-telemetry/opentelemetry-operator/internal/rbac" "github.com/open-telemetry/opentelemetry-operator/internal/version" "github.com/open-telemetry/opentelemetry-operator/internal/webhook/podmutation" @@ -111,6 +112,7 @@ func main() { pprofAddr string enableLeaderElection bool createRBACPermissions bool + createOpenShiftDashboard bool enableMultiInstrumentation bool enableApacheHttpdInstrumentation bool enableDotNetInstrumentation bool @@ -147,6 +149,7 @@ func main() { "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") pflag.BoolVar(&createRBACPermissions, "create-rbac-permissions", false, "Automatically create RBAC permissions needed by the processors (deprecated)") + pflag.BoolVar(&createOpenShiftDashboard, "create-openshift-dashboard", false, "Create an OpenShift dashboard for monitoring the OpenTelemetryCollector instances") pflag.BoolVar(&enableMultiInstrumentation, "enable-multi-instrumentation", false, "Controls whether the operator supports multi instrumentation") pflag.BoolVar(&enableApacheHttpdInstrumentation, constants.FlagApacheHttpd, true, "Controls whether the operator supports Apache HTTPD auto-instrumentation") pflag.BoolVar(&enableDotNetInstrumentation, constants.FlagDotNet, true, "Controls whether the operator supports dotnet auto-instrumentation") @@ -215,6 +218,7 @@ func main() { "enable-nginx-instrumentation", enableNginxInstrumentation, "enable-nodejs-instrumentation", enableNodeJSInstrumentation, "enable-java-instrumentation", enableJavaInstrumentation, + "create-openshift-dashboard", createOpenShiftDashboard, "zap-message-key", encodeMessageKey, "zap-level-key", encodeLevelKey, "zap-time-key", encodeTimeKey, @@ -277,9 +281,22 @@ func main() { setupLog.Error(clientErr, "failed to create kubernetes clientset") } - reviewer := rbac.NewReviewer(clientset) ctx := ctrl.SetupSignalHandler() + if createOpenShiftDashboard { + err = openshiftDashboards.CreateOpenShiftDashboard(clientset) + if err == nil { + ctrl.Log.Info("OpenShift dashboard for OpenTelemetryCollector monitoring created") + context.AfterFunc(ctx, func() { + openshiftDashboards.DeleteOpenShiftDashboard(clientset, ctrl.Log) + }) + } else { + ctrl.Log.Error(err, "Something failed while creating the OpenShift dashboard for OpenTelemetryCollector monitoring") + } + } + + reviewer := rbac.NewReviewer(clientset) + // builds the operator's configuration ad, err := autodetect.New(restConfig, reviewer) if err != nil {