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

Support of servicelabel config in GCP Metrics Metricset #41626

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ishleenk17
Copy link
Contributor

Proposed commit message

Explain here the changes you made on the PR.

Please explain:

  • WHAT: Addition of servicelabel config option to get the resource label for the new GCP service from the user
  • WHY: When the current metrics metricset was used for a new GCP service, the resource label used for data filtering was always the default "resource.label.zone", which may/may not be correct depending on the service. This PR get this label through config from the user.

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.

Related issues

Screenshots

Screenshot 2024-11-12 at 9 52 30 PM Screenshot 2024-11-12 at 9 52 48 PM

@ishleenk17 ishleenk17 self-assigned this Nov 13, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 13, 2024
@botelastic
Copy link

botelastic bot commented Nov 13, 2024

This pull request doesn't have a Team:<team> label.

Copy link
Contributor

mergify bot commented Nov 13, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @ishleenk17? 🙏.
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-8./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Nov 13, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Nov 13, 2024
Comment on lines +243 to +255
// isAnExistingService returns true if the given service is already an existing service supported by default in GCP module
func isAnExistingService(serviceName string) bool {
switch serviceName {
case gcp.ServiceCompute, gcp.ServiceGKE, gcp.ServiceStorage, gcp.ServiceDataproc,
gcp.ServicePubsub, gcp.ServiceLoadBalancing, gcp.ServiceCloudFunctions,
gcp.ServiceFirestore, gcp.ServiceCloudSQL, gcp.ServiceRedis:
return true
default:
return false
}

}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this functionality, we can just overwrite the label if ServiceLabel is set in config and that should be sufficient. If we decide to set the label from the integration side due to some GCP updates or whatever, having this function would actually defeat what we’re trying to achieve in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for not allowing override in existing supported services is for the filtering to work fine by using the existing location labels.
Yes, if GCP changes some label for these existing services at their end, we will have to do beats change for those existing services in beats module.
We can think of not having this function, but if existing customer puts in an incorrect label, it can break for him.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't expose this setting to users in normal GCP integrations. I think we should control this config option and update when necessary. I think it makes sense to allow users to set it for the GCP metrics input. What do you think?

@@ -103,6 +103,7 @@ type config struct {
Zone string `config:"zone"`
Region string `config:"region"`
Regions []string `config:"regions"`
ServiceLabel string `config:"servicelabel"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if LocationLabel (location_label) would be a better name for this config param. ServiceLabel feels too generic it could refer to any label, but here we’re specifically referring to region/zone/location labels 🤔

Comment on lines +48 to +51
* *servicelabel*: This config option is to add the resource label( eg:"resource.label.location") for a
GCP service to filter the data of the service. For a new service which is not supported by default
by Elastic, this label can be set by the user. If not set, tje default servicelabel (resource.label.zone)
will be chosen
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* *servicelabel*: This config option is to add the resource label( eg:"resource.label.location") for a
GCP service to filter the data of the service. For a new service which is not supported by default
by Elastic, this label can be set by the user. If not set, tje default servicelabel (resource.label.zone)
will be chosen
* *location_label*: Use this option to specify the resource label that identifies the location (such as zone or region) for a Google Cloud service when filtering metrics. For example, labels like `resource.labels.zone` or `resource.labels.region` are used by Google Cloud to represent the zone or region of a resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can go with location label. Lets finalize on the approach we want to take for existing services. Will update the description then

@ishleenk17 ishleenk17 marked this pull request as ready for review November 14, 2024 16:37
@ishleenk17 ishleenk17 requested review from a team as code owners November 14, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify enhancement needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support GCP region/zone for new services through Configuration
2 participants