-
Notifications
You must be signed in to change notification settings - Fork 61
Adds mysql prometheus exporter #100
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
.github/workflows/kustomize-prometheus-mysql-exporter.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Kustomize GitHub Actions for Prometheus MySql Exporter | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - kustomize/prometheus-mysql-exporter/** | ||
| - .github/workflows/kustomize-prometheus-mysql-exporter.yaml | ||
| jobs: | ||
| kustomize: | ||
| name: Kustomize | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - uses: azure/setup-helm@v3 | ||
| with: | ||
| version: latest | ||
| token: "${{ secrets.GITHUB_TOKEN }}" | ||
| id: helm | ||
| - name: Kustomize Install | ||
| working-directory: /usr/local/bin/ | ||
| run: | | ||
| if [ ! -f /usr/local/bin/kustomize ]; then | ||
| curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | sudo bash | ||
| fi | ||
| - name: Run Kustomize Build | ||
| run: | | ||
| kustomize build kustomize/prometheus-mysql-exporter/ --enable-helm --helm-command ${{ steps.helm.outputs.helm-path }} > /tmp/rendered.yaml | ||
| - name: Return Kustomize Build | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: kustomize-prometheus-mysql-exporter-artifact | ||
| path: /tmp/rendered.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ##Mariadb Exporter | ||
|
|
||
| Mysql Exporter is used to expose metrics from a running mysql/mariadb server. The type of metrics exposed is controlled | ||
| by the exporter and expressed in values.yaml file. | ||
|
|
||
| ##Installation | ||
|
|
||
| First create secret containing password for monitoring user | ||
| ``` | ||
| kubectl --namespace openstack \ | ||
| create secret generic mariadb-monitoring \ | ||
| --type Opaque \ | ||
| --from-literal=username="monitoring" \ | ||
| --from-literal=password="$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c${1:-64};echo;)" | ||
| ``` | ||
|
|
||
| Next, install the exporter | ||
|
|
||
| ``` | ||
| cd /opt/genestack/kustomize/prometheus-mysql-exporter | ||
|
|
||
| kubectl kustomize --enable-helm . | kubectl create -n openstack -f - | ||
| ``` | ||
|
|
||
| If the installation is succesful, you should see the exporter pod in openstack namespace. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| resources: | ||
| - monitoring_user_create.yaml | ||
| - monitoring_user_grant.yaml | ||
|
|
||
| helmCharts: | ||
| - name: prometheus-mysql-exporter | ||
| repo: https://prometheus-community.github.io/helm-charts | ||
| releaseName: prometheus-mysql-exporter | ||
| namespace: openstack | ||
| includeCRDs: true | ||
| valuesFile: values.yaml |
15 changes: 15 additions & 0 deletions
15
kustomize/prometheus-mysql-exporter/monitoring_user_create.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: mariadb.mmontes.io/v1alpha1 | ||
| kind: User | ||
| metadata: | ||
| name: monitoring | ||
| spec: | ||
| name: monitoring | ||
| mariaDbRef: | ||
| name: mariadb-galera | ||
| passwordSecretKeyRef: | ||
| name: mariadb-monitoring | ||
| key: password | ||
| maxUserConnections: 15 | ||
| host: "%" | ||
| requeueInterval: 30s | ||
| retryInterval: 5s |
18 changes: 18 additions & 0 deletions
18
kustomize/prometheus-mysql-exporter/monitoring_user_grant.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: mariadb.mmontes.io/v1alpha1 | ||
| kind: Grant | ||
| metadata: | ||
| name: monitoring-grant | ||
| spec: | ||
| mariaDbRef: | ||
| name: mariadb-galera | ||
| privileges: | ||
| - "SELECT" | ||
| - "PROCESS" | ||
| - "REPLICATION CLIENT" | ||
| database: "*" | ||
| table: "*" | ||
| username: monitoring | ||
| grantOption: false | ||
| host: "%" | ||
| requeueInterval: 30s | ||
| retryInterval: 5s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,218 @@ | ||
| ## Default values for prometheus-mysql-exporter. | ||
| ## This is a YAML-formatted file. | ||
| ## Declare variables to be passed into your templates. | ||
|
|
||
| ## namespaceOverride overrides the namespace which the resources will be deployed in | ||
| namespaceOverride: "" | ||
|
|
||
| ## override release name | ||
| fullnameOverride: "" | ||
|
|
||
| replicaCount: 1 | ||
|
|
||
| image: | ||
| registry: quay.io | ||
| repository: prometheus/mysqld-exporter | ||
| ## if not set charts appVersion var is used | ||
| tag: "" | ||
| pullPolicy: "IfNotPresent" | ||
|
|
||
| # imagePullSecrets: | ||
| # - name: secret-name | ||
| imagePullSecrets: [] | ||
|
|
||
| service: | ||
| labels: {} | ||
| annotations: {} | ||
| name: mysql-exporter | ||
| type: ClusterIP | ||
| externalPort: 9104 | ||
| internalPort: 9104 | ||
|
|
||
| serviceMonitor: | ||
| # enabled should be set to true to enable prometheus-operator discovery of this service | ||
| enabled: true | ||
| # interval is the interval at which metrics should be scraped | ||
| interval: 30s | ||
| # scrapeTimeout is the timeout after which the scrape is ended | ||
| scrapeTimeout: 10s | ||
| namespace: openstack | ||
| # namespaceSelector: [] | ||
| # additionalLabels is the set of additional labels to add to the ServiceMonitor | ||
| additionalLabels: {} | ||
| jobLabel: "" | ||
| targetLabels: [] | ||
| podTargetLabels: [] | ||
| metricRelabelings: [] | ||
| # Set relabel_configs as per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config | ||
| relabelings: [] | ||
| multipleTarget: | ||
| enabled: false | ||
| targets: | ||
| # target connection information with name (required), endpoint (required) and port (optionnal) | ||
| # if sharedSecret is not enabled the name must match an entry client.{{ name }} existing in the secret | ||
| # - endpoint: mysql1.dns.local | ||
| # name: mysql1 | ||
| # port: 3307 | ||
| # - endpoint: mysql2.dns.local | ||
| # name: mysql2 | ||
| # Enable shared credentials for all targets | ||
| sharedSecret: | ||
| enabled: false | ||
| name: "" | ||
|
|
||
| serviceAccount: | ||
| # Specifies whether a ServiceAccount should be created | ||
| create: false | ||
| # The name of the ServiceAccount to use. | ||
| # If not set and create is true, a name is generated using the fullname template | ||
| name: | ||
| annotations: {} | ||
|
|
||
| resources: {} | ||
| # We usually recommend not to specify default resources and to leave this as a conscious | ||
| # choice for the user. This also increases chances charts run on environments with little | ||
| # resources, such as Minikube. If you do want to specify resources, uncomment the following | ||
| # lines, adjust them as necessary, and remove the curly braces after 'resources:'. | ||
| # limits: | ||
| # cpu: 100m | ||
| # memory: 128Mi | ||
| # requests: | ||
| # cpu: 100m | ||
| # memory: 128Mi | ||
|
|
||
| nodeSelector: {} | ||
|
|
||
| tolerations: [] | ||
|
|
||
| affinity: {} | ||
|
|
||
| podLabels: {} | ||
|
|
||
| # Extra Volume Mounts for the mysql exporter container | ||
| extraVolumeMounts: [] | ||
| # - name: example | ||
| # mountPath: /example | ||
|
|
||
| # Extra Volumes for the pod | ||
| extraVolumes: [] | ||
| # - name: example | ||
| # configMap: | ||
| # name: example | ||
|
|
||
| podSecurityContext: {} | ||
| # fsGroup: 65534 | ||
|
|
||
| securityContext: {} | ||
| # capabilities: | ||
| # drop: | ||
| # - ALL | ||
| # readOnlyRootFilesystem: true | ||
| # runAsNonRoot: true | ||
| # runAsUser: 65534 | ||
|
|
||
| annotations: | ||
| prometheus.io/scrape: "true" | ||
| prometheus.io/path: "/metrics" | ||
| prometheus.io/port: "9104" | ||
|
|
||
| config: {} | ||
| # Allow to set specifc options on the exporter | ||
| # logLevel: info | ||
| # logFormat: "logger:stderr" | ||
|
|
||
| collectors: | ||
| # auto_increment.columns: false | ||
| # binlog_size: false | ||
| # engine_innodb_status: false | ||
| # engine_tokudb_status: false | ||
| # global_status: true | ||
| # global_variables: true | ||
| # info_schema.clientstats: false | ||
| # info_schema.innodb_metrics: false | ||
| # info_schema.innodb_tablespaces: false | ||
| # info_schema.innodb_cmp: false | ||
| # info_schema.innodb_cmpmem: false | ||
| # info_schema.processlist: false | ||
| # info_schema.processlist.min_time: 0 | ||
| # info_schema.query_response_time: false | ||
| # info_schema.tables: true | ||
| # info_schema.tables.databases: '*' | ||
| # info_schema.tablestats: false | ||
| # info_schema.schemastats: false | ||
| # info_schema.userstats: false | ||
| # perf_schema.eventsstatements: false | ||
| # perf_schema.eventsstatements.digest_text_limit: 120 | ||
| # perf_schema.eventsstatements.limit: false | ||
| # perf_schema.eventsstatements.timelimit: 86400 | ||
| # perf_schema.eventswaits: false | ||
| # perf_schema.file_events: false | ||
| # perf_schema.file_instances: false | ||
| # perf_schema.indexiowaits: false | ||
| # perf_schema.tableiowaits: false | ||
| # perf_schema.tablelocks: false | ||
| # perf_schema.replication_group_member_stats: false | ||
| # slave_status: true | ||
| # slave_hosts: false | ||
| # heartbeat: false | ||
| # heartbeat.database: heartbeat | ||
| # heartbeat.table: heartbeat | ||
|
|
||
| # mysql connection params which build the my.cnf config | ||
| mysql: | ||
| db: "" | ||
| host: "mariadb-galera" | ||
| # config my.cnf https://dev.mysql.com/doc/c-api/8.0/en/mysql-options.html | ||
| additionalConfig: | ||
| # - connect-timeout=5 | ||
| # - debug | ||
| pass: "password" | ||
| port: 3306 | ||
| protocol: "" | ||
| user: "monitoring" | ||
| # secret with full config my.cnf | ||
| existingConfigSecret: | ||
| name: "" | ||
| key: "" | ||
| # secret only containing the password | ||
| existingPasswordSecret: | ||
| name: "mariadb-monitoring" | ||
| key: "password" | ||
|
|
||
| # cloudsqlproxy https://cloud.google.com/sql/docs/mysql/sql-proxy | ||
| cloudsqlproxy: | ||
| enabled: false | ||
| image: | ||
| repo: "gcr.io/cloud-sql-connectors/cloud-sql-proxy" | ||
| tag: "2.4.0" | ||
| pullPolicy: "IfNotPresent" | ||
| instanceConnectionName: "project:us-central1:dbname" | ||
| privateIp: false | ||
| port: "3306" | ||
| credentialsSecret: "" | ||
| # service account json | ||
| credentials: "" | ||
| workloadIdentity: | ||
| enabled: false | ||
| serviceAccountEmail: "" | ||
| extraArgs: "" | ||
|
|
||
| ## Custom PrometheusRules to be defined | ||
| ## The value is evaluated as a template, so, for example, the value can depend on .Release or .Chart | ||
| ## ref: https://github.com/coreos/prometheus-operator#customresourcedefinitions | ||
| prometheusRule: | ||
| enabled: false | ||
| additionalLabels: {} | ||
| namespace: "" | ||
| rules: | ||
| [] | ||
| ## These are just examples rules, please adapt them to your needs. | ||
| ## Make sure to constraint the rules to the current service. | ||
| # - alert: MysqlDown | ||
| # expr: mysql_up == 0 | ||
| # for: 5m | ||
| # labels: | ||
| # severity: critical | ||
| # annotations: | ||
| # summary: MySQL down (instance {{ $labels.instance }}) | ||
| # description: "MySQL instance is down on {{ $labels.instance }}\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to add 'cd /opt/genestack/kustomize/prometheus-mysql-exporter' here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created secret as noted in doc but getting issue as the scraper runs:
s=2024-02-28T21:14:25.903Z caller=exporter.go:173 level=error msg="Error from scraper" scraper=slave_status target=mariadb-galera:3306 err="Error 1227 (42000): Access denied; you need (at least one of) the SLAVE MONITOR privilege(s) for this operation"