Skip to content
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

Feature/32089 generic sql enchancement #32293

Merged

Conversation

agithomas
Copy link
Contributor

@agithomas agithomas commented Jul 11, 2022

Type of change
Please label this PR with one of the following labels, depending on the scope of your change:

  • Enhancement

What does this PR do?

Enhance the GenericSQL module to support below mentioned features and resolve below mentioned issues

Connection string for Oracle does not handle special characters properly
Modify the driver used for oracle connectivity
Integration testing not available for GenericSQL Oracle integration
System testing for GenericSQL oracle is not adequate

Why is it important?

Ensures that the customer can use special characters while configuring connectivity parameters
Ensures new connection string format is supported

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • Integration testing with support for multiple databases.
  • System testing included

How to test this PR locally

INTEGRATION_TESTS=1 python3 -m pytest x-pack/metricbeat/module/sql/test_sql_oracle.py

Related issues

-Relates [#32089]

Use cases

Screenshots

Logs

{
  "_index": ".ds-metricbeat-8.4.0-2022.07.07-000001",
  "_id": "0Xnv2IEBhSE0tE7x20BG",
  "_version": 1,
  "_score": 1,
  "_source": {
    "@timestamp": "2022-07-07T13:53:25.802Z",
    "cloud": {
      "project": {
        "id": "elastic-obs-integrations-dev"
      },
      "account": {
        "id": "elastic-obs-integrations-dev"
      },
      "provider": "gcp",
      "service": {
        "name": "GCE"
      },
      "instance": {
        "id": "3010911784348669868",
        "name": "service-integration-dev-idc-01"
      },
      "machine": {
        "type": "n1-standard-8"
      },
      "availability_zone": "asia-south1-c"
    },
    "event": {
      "dataset": "sql.query",
      "module": "sql",
      "duration": 50648328
    },
    "metricset": {
      "period": 10000,
      "name": "query"
    },
    "service": {
      "type": "sql",
      "address": "(redacted)"
    },
    "sql": {
      "metrics": {
        "numeric": {
          "physical_reads": 18777,
          "db_block_gets": 28195,
          "consistent_gets": 401043,
          "hit ratio": 0.9562550379975678
        },
        "string": {
          "name": "DEFAULT"
        }
      },
      "driver": "oracle",
      "query": "SELECT name, physical_reads, db_block_gets, consistent_gets, 1 - (physical_reads / (db_block_gets + consistent_gets)) \"Hit Ratio\" FROM V$BUFFER_POOL_STATISTICS"
    },
    "ecs": {
      "version": "8.0.0"
    },
    "host": {
      "mac": [
        "02:42:0e:57:e0:74",
        "02:42:30:c0:73:71",
        "02:42:4e:40:3e:93",
        "02:42:77:c9:50:db",
        "02:83:25:54:e5:c9",
        "0a:47:44:c1:bf:ac",
        "42:01:0a:a0:00:03",
        "86:11:73:f0:90:ce",
        "a2:43:4c:cc:01:35",
        "b2:3f:b9:04:64:78",
        "d6:94:46:b4:a0:c2"
      ],
      "hostname": "service-integration-dev-idc-01",
      "architecture": "x86_64",
      "os": {
        "kernel": "5.4.0-1078-gcp",
        "codename": "bionic",
        "type": "linux",
        "platform": "ubuntu",
        "version": "18.04.6 LTS (Bionic Beaver)",
        "family": "debian",
        "name": "Ubuntu"
      },
      "id": "1bfc9b2d8959f75a520a3cb94cf035c8",
      "name": "service-integration-dev-idc-01",
      "containerized": false,
      "ip": [
        "10.160.0.3",
        "fe80::4001:aff:fea0:3",
        "172.20.0.1",
        "172.17.0.1",
        "fe80::42:77ff:fec9:50db",
        "172.19.0.1",
        "fe80::42:30ff:fec0:7371",
        "172.26.0.1",
        "fe80::42:4eff:fe40:3e93",
        "fe80::8411:73ff:fef0:90ce",
        "fe80::83:25ff:fe54:e5c9",
        "fe80::b03f:b9ff:fe04:6478",
        "fe80::847:44ff:fec1:bfac",
        "fe80::d494:46ff:feb4:a0c2",
        "fe80::a043:4cff:fecc:135"
      ]
    },
    "agent": {
      "id": "fe7a78e7-c123-4c21-a559-78e3142845ff",
      "name": "service-integration-dev-idc-01",
      "type": "metricbeat",
      "version": "8.4.0",
      "ephemeral_id": "97bc610f-230a-498d-abd4-c7177298037a"
    }
  },
  "fields": {
    "host.os.name.text": [
      "Ubuntu"
    ],
    "host.hostname": [
      "service-integration-dev-idc-01"
    ],
    "host.mac": [
      "02:42:0e:57:e0:74",
      "02:42:30:c0:73:71",
      "02:42:4e:40:3e:93",
      "02:42:77:c9:50:db",
      "02:83:25:54:e5:c9",
      "0a:47:44:c1:bf:ac",
      "42:01:0a:a0:00:03",
      "86:11:73:f0:90:ce",
      "a2:43:4c:cc:01:35",
      "b2:3f:b9:04:64:78",
      "d6:94:46:b4:a0:c2"
    ],
    "cloud.availability_zone": [
      "asia-south1-c"
    ],
    "service.type": [
      "sql"
    ],
    "host.os.version": [
      "18.04.6 LTS (Bionic Beaver)"
    ],
    "host.os.name": [
      "Ubuntu"
    ],
    "sql.query": [
      "SELECT name, physical_reads, db_block_gets, consistent_gets, 1 - (physical_reads / (db_block_gets + consistent_gets)) \"Hit Ratio\" FROM V$BUFFER_POOL_STATISTICS"
    ],
    "agent.name": [
      "service-integration-dev-idc-01"
    ],
    "host.name": [
      "service-integration-dev-idc-01"
    ],
    "beats_state.state.host.name": [
      "service-integration-dev-idc-01"
    ],
    "host.os.type": [
      "linux"
    ],
    "agent.hostname": [
      "service-integration-dev-idc-01"
    ],
    "host.architecture": [
      "x86_64"
    ],
    "cloud.machine.type": [
      "n1-standard-8"
    ],
    "cloud.provider": [
      "gcp"
    ],
    "agent.id": [
      "fe7a78e7-c123-4c21-a559-78e3142845ff"
    ],
    "cloud.service.name": [
      "GCE"
    ],
    "ecs.version": [
      "8.0.0"
    ],
    "host.containerized": [
      false
    ],
    "service.address": [
      "(redacted)"
    ],
    "sql.metrics.numeric.hit ratio": [
      0.9562550379975678
    ],
    "agent.version": [
      "8.4.0"
    ],
    "host.os.family": [
      "debian"
    ],
    "sql.metrics.string.name": [
      "DEFAULT"
    ],
    "beats_state.state.host.hostname": [
      "service-integration-dev-idc-01"
    ],
    "sql.metrics.numeric.consistent_gets": [
      401043
    ],
    "host.ip": [
      "10.160.0.3",
      "fe80::4001:aff:fea0:3",
      "172.20.0.1",
      "172.17.0.1",
      "fe80::42:77ff:fec9:50db",
      "172.19.0.1",
      "fe80::42:30ff:fec0:7371",
      "172.26.0.1",
      "fe80::42:4eff:fe40:3e93",
      "fe80::8411:73ff:fef0:90ce",
      "fe80::83:25ff:fe54:e5c9",
      "fe80::b03f:b9ff:fe04:6478",
      "fe80::847:44ff:fec1:bfac",
      "fe80::d494:46ff:feb4:a0c2",
      "fe80::a043:4cff:fecc:135"
    ],
    "cloud.instance.id": [
      "3010911784348669868"
    ],
    "agent.type": [
      "metricbeat"
    ],
    "sql.metrics.numeric.db_block_gets": [
      28195
    ],
    "logstash_stats.timestamp": [
      "2022-07-07T13:53:25.802Z"
    ],
    "event.module": [
      "sql"
    ],
    "host.os.kernel": [
      "5.4.0-1078-gcp"
    ],
    "beats_state.timestamp": [
      "2022-07-07T13:53:25.802Z"
    ],
    "host.id": [
      "1bfc9b2d8959f75a520a3cb94cf035c8"
    ],
    "timestamp": [
      "2022-07-07T13:53:25.802Z"
    ],
    "sql.metrics.numeric.physical_reads": [
      18777
    ],
    "sql.driver": [
      "oracle"
    ],
    "kibana_stats.timestamp": [
      "2022-07-07T13:53:25.802Z"
    ],
    "metricset.period": [
      10000
    ],
    "host.os.codename": [
      "bionic"
    ],
    "metricset.name": [
      "query"
    ],
    "event.duration": [
      50648328
    ],
    "@timestamp": [
      "2022-07-07T13:53:25.802Z"
    ],
    "host.os.platform": [
      "ubuntu"
    ],
    "cloud.account.id": [
      "elastic-obs-integrations-dev"
    ],
    "agent.ephemeral_id": [
      "97bc610f-230a-498d-abd4-c7177298037a"
    ],
    "beats_state.state.host.architecture": [
      "x86_64"
    ],
    "event.dataset": [
      "sql.query"
    ],
    "cloud.instance.name": [
      "service-integration-dev-idc-01"
    ],
    "cloud.project.id": [
      "elastic-obs-integrations-dev"
    ]
  }
}

@agithomas agithomas requested a review from a team as a code owner July 11, 2022 06:00
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 11, 2022
@agithomas agithomas added the Team:Service-Integrations Label for the Service Integrations team label Jul 11, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 11, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 11, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-11-15T08:57:10.916+0000

  • Duration: 67 min 48 sec

Test stats 🧪

Test Results
Failed 0
Passed 4115
Skipped 1006
Total 5121

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Contributor

mergify bot commented Jul 11, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b feature/32089-generic-sql-enchancement upstream/feature/32089-generic-sql-enchancement
git merge upstream/main
git push upstream feature/32089-generic-sql-enchancement

@lalit-satapathy
Copy link
Contributor

@agithomas,

Can you update the documentation with the details usage case for the oracle changes?

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some additional suggestions to the documentation, for the rest it looks good.

metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Show resolved Hide resolved
@agithomas
Copy link
Contributor Author

Looks good in general, nice to see more tests for this. I am requesting changes mainly for the organization of the docs. Also for refactoring DSN handling so the handling for the different drivers is in a single place, but this could be also a future change too.

Will be targetted as part of other enhancements planned in 8.7

@agithomas
Copy link
Contributor Author

/test

@agithomas
Copy link
Contributor Author

@jsoriano , all review comments are addressed. Can you please take a final look at the changes and approve, if all good?

@jsoriano jsoriano dismissed their stale review November 14, 2022 17:22

Most changes addressed.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some details in docs formatting.

metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/sql.asciidoc Outdated Show resolved Hide resolved
@agithomas
Copy link
Contributor Author

Some details in docs formatting.

All suggestions considered and changes made to the documentation

@agithomas agithomas merged commit 7be50c0 into elastic:main Nov 17, 2022
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
* Upgrade Generic SQL to support new connection string and special character support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Service-Integrations Label for the Service Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants