Skip to content

[MySQL] Add condition setting support#9704

Closed
BenB196 wants to merge 8 commits intoelastic:mainfrom
BenB196:mysql-condition-support
Closed

[MySQL] Add condition setting support#9704
BenB196 wants to merge 8 commits intoelastic:mainfrom
BenB196:mysql-condition-support

Conversation

@BenB196
Copy link
Copy Markdown
Contributor

@BenB196 BenB196 commented Apr 25, 2024

Enhancement

Proposed commit message

This MR adds the ability to set Elastic Agent condition to both the Log and Metrics datasets.

The ability to set this value allows for having multiple MySQL integrations in the same Agent policy while only having them run on specific hosts. (Most likely to be used with the host metadata; ex; host.name or host.platform.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • I added condition as "advanced" fields, similar to other integrations that have this setting.
Before Upgrade
inputs:
  - id: logfile-mysql-1d521dab-3d64-48c7-ac99-99d6985fe9de
    name: mysql-1
    revision: 1
    type: logfile
    use_output: default
    meta:
      package:
        name: mysql
        version: 1.19.0
    data_stream:
      namespace: default
    package_policy_id: 1d521dab-3d64-48c7-ac99-99d6985fe9de
    streams:
      - id: logfile-mysql.error-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.error
          type: logs
        paths:
          - /var/log/mysql/error.log*
          - /var/log/mysqld.log*
        exclude_files:
          - .gz$
        multiline:
          pattern: '^([0-9]{4}-[0-9]{2}-[0-9]{2}|[0-9]{6})'
          negate: true
          match: after
        tags:
          - mysql-error
        processors:
          - add_locale: null
      - id: logfile-mysql.slowlog-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.slowlog
          type: logs
        paths:
          - /var/log/mysql/*-slow.log*
          - /var/lib/mysql/*-slow.log*
        exclude_files:
          - .gz$
        multiline:
          pattern: '^(# User@Host: |# Time: )'
          negate: true
          match: after
        exclude_lines:
          - '^[\/\w\.]+, Version: .* started with:.*'
          - '^# Time:.*'
        tags:
          - mysql-slowlog
        processors:
          - add_locale: null
  - id: mysql/metrics-mysql-1d521dab-3d64-48c7-ac99-99d6985fe9de
    name: mysql-1
    revision: 1
    type: mysql/metrics
    use_output: default
    meta:
      package:
        name: mysql
        version: 1.19.0
    data_stream:
      namespace: default
    package_policy_id: 1d521dab-3d64-48c7-ac99-99d6985fe9de
    streams:
      - id: mysql/metrics-mysql.performance-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.performance
          type: metrics
        metricsets:
          - performance
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
      - id: mysql/metrics-mysql.status-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.status
          type: metrics
        metricsets:
          - status
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
After Upgrade (no changes)
inputs:
  - id: logfile-mysql-1d521dab-3d64-48c7-ac99-99d6985fe9de
    name: mysql-1
    revision: 2
    type: logfile
    use_output: default
    meta:
      package:
        name: mysql
        version: 1.20.0
    data_stream:
      namespace: default
    package_policy_id: 1d521dab-3d64-48c7-ac99-99d6985fe9de
    streams:
      - id: logfile-mysql.error-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.error
          type: logs
        paths:
          - /var/log/mysql/error.log*
          - /var/log/mysqld.log*
        exclude_files:
          - .gz$
        multiline:
          pattern: '^([0-9]{4}-[0-9]{2}-[0-9]{2}|[0-9]{6})'
          negate: true
          match: after
        tags:
          - mysql-error
        processors:
          - add_locale: null
      - id: logfile-mysql.slowlog-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.slowlog
          type: logs
        paths:
          - /var/log/mysql/*-slow.log*
          - /var/lib/mysql/*-slow.log*
        exclude_files:
          - .gz$
        multiline:
          pattern: '^(# User@Host: |# Time: )'
          negate: true
          match: after
        exclude_lines:
          - '^[\/\w\.]+, Version: .* started with:.*'
          - '^# Time:.*'
        tags:
          - mysql-slowlog
        processors:
          - add_locale: null
  - id: mysql/metrics-mysql-1d521dab-3d64-48c7-ac99-99d6985fe9de
    name: mysql-1
    revision: 2
    type: mysql/metrics
    use_output: default
    meta:
      package:
        name: mysql
        version: 1.20.0
    data_stream:
      namespace: default
    package_policy_id: 1d521dab-3d64-48c7-ac99-99d6985fe9de
    streams:
      - id: mysql/metrics-mysql.performance-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.performance
          type: metrics
        metricsets:
          - performance
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
      - id: mysql/metrics-mysql.status-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.status
          type: metrics
        metricsets:
          - status
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
After Upgrade (with `condition` set)
inputs:
  - id: logfile-mysql-1d521dab-3d64-48c7-ac99-99d6985fe9de
    name: mysql-1
    revision: 3
    type: logfile
    use_output: default
    meta:
      package:
        name: mysql
        version: 1.20.0
    data_stream:
      namespace: default
    package_policy_id: 1d521dab-3d64-48c7-ac99-99d6985fe9de
    streams:
      - id: logfile-mysql.error-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.error
          type: logs
        paths:
          - /var/log/mysql/error.log*
          - /var/log/mysqld.log*
        exclude_files:
          - .gz$
        multiline:
          pattern: '^([0-9]{4}-[0-9]{2}-[0-9]{2}|[0-9]{6})'
          negate: true
          match: after
        tags:
          - mysql-error
        processors:
          - add_locale: null
        condition: '${host.name} == "mydb-server"'
      - id: logfile-mysql.slowlog-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.slowlog
          type: logs
        paths:
          - /var/log/mysql/*-slow.log*
          - /var/lib/mysql/*-slow.log*
        exclude_files:
          - .gz$
        multiline:
          pattern: '^(# User@Host: |# Time: )'
          negate: true
          match: after
        exclude_lines:
          - '^[\/\w\.]+, Version: .* started with:.*'
          - '^# Time:.*'
        tags:
          - mysql-slowlog
        processors:
          - add_locale: null
        condition: '${host.name} == "mydb-server"'
  - id: mysql/metrics-mysql-1d521dab-3d64-48c7-ac99-99d6985fe9de
    name: mysql-1
    revision: 3
    type: mysql/metrics
    use_output: default
    meta:
      package:
        name: mysql
        version: 1.20.0
    data_stream:
      namespace: default
    package_policy_id: 1d521dab-3d64-48c7-ac99-99d6985fe9de
    streams:
      - id: mysql/metrics-mysql.galera_status-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.galera_status
          type: metrics
        metricsets:
          - galera_status
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
        condition: '${host.name} == "mydb-server"'
      - id: mysql/metrics-mysql.performance-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.performance
          type: metrics
        metricsets:
          - performance
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
        condition: '${host.name} == "mydb-server"'
      - id: mysql/metrics-mysql.status-1d521dab-3d64-48c7-ac99-99d6985fe9de
        data_stream:
          dataset: mysql.status
          type: metrics
        metricsets:
          - status
        hosts:
          - 'tcp(127.0.0.1:3306)/'
        password: '${SECRET_0}'
        period: 10s
        username: root
        condition: '${host.name} == "mydb-server"'

How to test this PR locally

  1. Install current integration version
  2. Upgrade integration to this PR
  3. Add/Remove condition values.

Related issues

Screenshots

image

image

@BenB196 BenB196 requested a review from a team as a code owner April 25, 2024 00:02
@ishleenk17
Copy link
Copy Markdown
Member

Changes look fine.
Retriggering the CI.

@ishleenk17
Copy link
Copy Markdown
Member

/test

1 similar comment
@kush-elastic
Copy link
Copy Markdown
Contributor

/test

@botelastic
Copy link
Copy Markdown

botelastic bot commented Jun 29, 2024

Hi! We just realized that we haven't looked into this PR in a while. We're sorry! We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1. Thank you for your contribution!

@botelastic botelastic bot added the Stalled label Jun 29, 2024
@botelastic botelastic bot removed the Stalled label Jul 19, 2024
@andrewkroh andrewkroh added the Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] label Jul 19, 2024
@botelastic
Copy link
Copy Markdown

botelastic bot commented Aug 18, 2024

Hi! We just realized that we haven't looked into this PR in a while. We're sorry! We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1. Thank you for your contribution!

@botelastic botelastic bot added the Stalled label Aug 18, 2024
@andrewkroh andrewkroh added the enhancement New feature or request label Aug 19, 2024
@botelastic botelastic bot removed the Stalled label Aug 19, 2024
@ishleenk17
Copy link
Copy Markdown
Member

/test

@ishleenk17
Copy link
Copy Markdown
Member

/test

@elasticmachine
Copy link
Copy Markdown

elasticmachine commented Sep 9, 2024

💔 Build Failed

Failed CI Steps

History

@elastic-sonarqube
Copy link
Copy Markdown

@botelastic
Copy link
Copy Markdown

botelastic bot commented Oct 9, 2024

Hi! We just realized that we haven't looked into this PR in a while. We're sorry! We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1. Thank you for your contribution!

@botelastic botelastic bot added the Stalled label Oct 9, 2024
@botelastic
Copy link
Copy Markdown

botelastic bot commented Nov 8, 2024

Hi! This PR has been stale for a while and we're going to close it as part of our cleanup procedure. We appreciate your contribution and would like to apologize if we have not been able to review it, due to the current heavy load of the team. Feel free to re-open this PR if you think it should stay open and is worth rebasing. Thank you for your contribution!

@botelastic botelastic bot closed this Nov 8, 2024
@BenB196 BenB196 deleted the mysql-condition-support branch February 24, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Integration:mysql MySQL Stalled Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants