From 728f83d858de8a85a95ef7e7043415063791a6cb Mon Sep 17 00:00:00 2001 From: Matej Gera Date: Fri, 14 Jul 2023 12:18:15 +0200 Subject: [PATCH 1/3] Add values for MySQL preset Signed-off-by: Matej Gera --- otel-agent/k8s-helm/values-crd.yaml | 11 +++++++++++ otel-agent/k8s-helm/values.yaml | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/otel-agent/k8s-helm/values-crd.yaml b/otel-agent/k8s-helm/values-crd.yaml index 97f8ef84..a9cdc88d 100644 --- a/otel-agent/k8s-helm/values-crd.yaml +++ b/otel-agent/k8s-helm/values-crd.yaml @@ -38,6 +38,17 @@ opentelemetry-collector: kubeletMetrics: enabled: true + mysql: + metrics: + enabled: false + instances: + - username: "" + password: "" + extraLogs: + enabled: false + volumeMountName: "" + mountPath: "" + extraEnvs: - name: CORALOGIX_PRIVATE_KEY valueFrom: diff --git a/otel-agent/k8s-helm/values.yaml b/otel-agent/k8s-helm/values.yaml index 6484d1bc..d8c98128 100644 --- a/otel-agent/k8s-helm/values.yaml +++ b/otel-agent/k8s-helm/values.yaml @@ -46,6 +46,17 @@ opentelemetry-collector: kubeletMetrics: enabled: true + mysql: + metrics: + enabled: false + instances: + - username: "" + password: "" + extraLogs: + enabled: false + volumeMountName: "" + mountPath: "" + extraEnvs: - name: CORALOGIX_PRIVATE_KEY valueFrom: From fd6a182e7a19b3a8ed802f647c9db228457d6ae4 Mon Sep 17 00:00:00 2001 From: Matej Gera Date: Fri, 14 Jul 2023 12:18:33 +0200 Subject: [PATCH 2/3] Add README section for MySQL preset Signed-off-by: Matej Gera --- otel-agent/k8s-helm/README.md | 89 +++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/otel-agent/k8s-helm/README.md b/otel-agent/k8s-helm/README.md index 136bc737..bc9cbc59 100644 --- a/otel-agent/k8s-helm/README.md +++ b/otel-agent/k8s-helm/README.md @@ -124,6 +124,95 @@ env: value: "$(NODE):4317" ``` +# Integration presets + +The `otel-agent` chart also provides support to integrate with different applications. The following integration presets are available. + +## MySQL + +The MySQL preset is able to collect metrics and extra logs (slow query log, general query log) from your MySQL instances. **Extra logs collection is available only when running the `otel-agent` as CRD with the OpenTelemetry Operator.** + +### Prerequisites + +This preset supports MySQL version 8.0 + +Collecting most metrics requires the ability of the database user to execute `SHOW GLOBAL STATUS`. + +### Configuration for metrics collection + +The metrics collection has to be enabled by setting the `metrics.enabled` to `true`. + +Each MySQL instance is configured in the `metrics.instances` section. You can configure multiple instances, if you have more than one instance you'd like to monitor. + +Required instance settings: +- `username`: The username of the database user that will be used to collect metrics. +- `password`: The password of the database user that will be used to collect metrics. We strongly recommend to provide this via a Kuberetes secret as an environment variable, e.g `MYSQL_PASSWORD`, which should be provided in the `extraEnv` section of the chart. This parameter should be passed in format `${env:MYSQL_PASSWORD}` in order for the collector to be able to read it. + +Optional instance settings: +- `port`: The port of the MySQL instance. Defaults to `3306`. Unless you use non-standard port, there is no need to set this parameter. +- `labelSelectors`: A list of label selectors to select the pods that run the MySQL instances. If you wish to monitor mutiple instance, the selectors will determine which pods belong to a given instance. + +### Configuration for extra logs collection + +The extra logs collection has to be enabled by setting the `extraLogs.enabled` to `true`. Note that the extra logs have to enabled on your MySQL instance (please refer to https://dev.mysql.com/doc/refman/8.0/en/server-logs.html). Please also note that extra logs collection is only available when running `otel-agent` with OpenTelemetry Operator. + +**PLEASE NOTE:** In order for the collection to take effect, you need to annotate your MySQL instance(s) pod templates with the following: + +```bash +kubectl patch sts -p '{"spec": {"template":{"metadata":{"annotations":{"sidecar.opentelemetry.io/inject":"otel-coralogix-mysql-logs-sidecar"}}}} }' +``` + +Required settings: +- `volumeMountName`: specifies the name of the volume mount. It should correspond to the volume name of the MySQL data volume. +- `mountPath`: specifies the path at which to mount the volume. This should correspond the mount path of your MySQL data volume. Provide this parameter without trailing slash. + +Optional settings: +- `logFilesPath`: specifies which directory to watch for log files. This will typically be the MySQL data directory, + such as `/var/lib/mysql`. If not specified, the value of `mountPath` will be used. +- `logFilesExtension`: specifies which file extensions to watch for. Defaults to `.log`. + +### Common issues + +- Metrics collection is failing with error `"Error 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this operation"` + - This error indicates that the database user you provided does not have the required privileges to collect metrics. Provide the `PROCESS` privilege to the user, e.g. by running query + `GRANT PROCESS ON *.* TO 'user'@'%'` + +### Example preset configuration for single instance + +```yaml + mysql: + metrics: + enabled: true + instances: + - username: "otel-agent" + password: ${env:MYSQL_PASSWORD} + extraLogs: + enabled: true + volumeMountName: "data" + mountPath: "/var/log/mysql" +``` + +### Example preset configuration for multiple instance + +```yaml + mysql: + metrics: + enabled: true + instances: + - username: "otel-agent" + password: ${env:MYSQL_PASSWORD_INSTANCE_A} + labelSelectors: + app.kubernetes.io/name: "mysql-a" + - username: "otel-agent" + password: ${env:MYSQL_PASSWORD_INSTANCE_B} + labelSelectors: + app.kubernetes.io/name: "mysql-b" + extraLogs: + enabled: true + volumeMountName: "data" + mountPath: "/var/log/mysql" +``` + # Performance of the Collector ## Picking the right tracing SDK span processor From 30ff17dfdf258625272dab1ba3f7c84ddc4295b0 Mon Sep 17 00:00:00 2001 From: Matej Gera Date: Fri, 14 Jul 2023 12:21:27 +0200 Subject: [PATCH 3/3] Bump chart and add CHANGELOG Signed-off-by: Matej Gera --- otel-agent/k8s-helm/CHANGELOG.md | 4 ++++ otel-agent/k8s-helm/Chart.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/otel-agent/k8s-helm/CHANGELOG.md b/otel-agent/k8s-helm/CHANGELOG.md index 681994cc..b2919f4e 100644 --- a/otel-agent/k8s-helm/CHANGELOG.md +++ b/otel-agent/k8s-helm/CHANGELOG.md @@ -2,6 +2,10 @@ ## OpenTelemtry-Agent +### v0.0.29 / 2023-07-14 + +* [FEATURE] Add MySQL preset for metrics and extra logs. + ### v0.0.28 / 2023-07-03 * [FEATURE] Add domain validation via `NOTES.txt`. diff --git a/otel-agent/k8s-helm/Chart.yaml b/otel-agent/k8s-helm/Chart.yaml index ad9145b1..712f9e17 100644 --- a/otel-agent/k8s-helm/Chart.yaml +++ b/otel-agent/k8s-helm/Chart.yaml @@ -1,14 +1,14 @@ apiVersion: v2 name: opentelemetry-coralogix description: OpenTelemetry agent to which instrumentation libraries export their telemetry data -version: 0.0.28 +version: 0.0.29 keywords: - OpenTelemetry Collector - OpenTelemetry agent - Coralogix dependencies: - name: opentelemetry-collector - version: "0.62.1" + version: "0.63.0" repository: https://cgx.jfrog.io/artifactory/coralogix-charts-virtual sources: - https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector