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

Added support for shards total count in Elasticsearch Module #38891

Conversation

philippkahr
Copy link
Contributor

@philippkahr philippkahr commented Apr 12, 2024

Hi,

I just added the support for the shards_stats.total_count which can be nice for alerting, since a lot of shards on a single node can impact performance.

Question: if I fix it here, that means it is fixed for the Elastic Agent integration package as well?

GET /_nodes/_all/stats?filter_path=*.*.*.shard_stats.*

Retrieves:

{
  "nodes": {
    "NXSI_2XFQaC2HH7ZvdTJuQ": {
      "indices": {
        "shard_stats": {
          "total_count": 0
        }
      }
    },
    "36aFMv40QX6MBZ4u1DsCCQ": {
      "indices": {
        "shard_stats": {
          "total_count": 0
        }
      }
    },
    "g2N_KasgRkuBEvD529XfhQ": {
      "indices": {
        "shard_stats": {
          "total_count": 1753
        }
      }
    },
    "ObCmi3u1Rhiyp4JTosFXdw": {
      "indices": {
        "shard_stats": {
          "total_count": 866
        }
      }
    },
    "AW982puiTbq-RNJpg23QEw": {
      "indices": {
        "shard_stats": {
          "total_count": 866
        }
      }
    }
  }
}

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.

@philippkahr philippkahr requested a review from a team as a code owner April 12, 2024 14:02
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 12, 2024
Copy link
Contributor

mergify bot commented Apr 12, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @philippkahr? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 12, 2024

💚 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

  • Duration: 50 min 33 sec

Test stats 🧪

Test Results
Failed 0
Passed 4621
Skipped 915
Total 5536

💚 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!)

Copy link
Contributor

@miltonhultgren miltonhultgren left a comment

Choose a reason for hiding this comment

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

These changes look good but we'll need to update the mappings for the xpack mode which live here in the Elasticsearch repo as well as the mappings for the Integration which live here.

@philippkahr
Copy link
Contributor Author

philippkahr commented Apr 15, 2024

@miltonhultgren :

ES: elastic/elasticsearch#107471
Integration: elastic/integrations#9594

@philippkahr philippkahr enabled auto-merge (squash) April 15, 2024 14:41
@smith smith added the Team:Monitoring Stack Monitoring team label Apr 15, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 15, 2024
@philippkahr philippkahr disabled auto-merge April 16, 2024 06:00
Copy link
Contributor

@miltonhultgren miltonhultgren left a comment

Choose a reason for hiding this comment

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

I should have reviewed this more carefully yesterday!

We first need to wrap the access in a c.Dict to go into indices.shard_stats in the response, where we'll then find the field total_count. We also make that Dict optional so in case it's not there (as in older versions) we just skip grabbing that stat.

This should make the tests pass.

metricbeat/module/elasticsearch/node_stats/data.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Team:Monitoring Stack Monitoring team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants