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

[Metricbeat] Add Load Balancing metricset to Google Cloud Platform module #15559

Merged
merged 11 commits into from
Feb 14, 2020

Conversation

sayden
Copy link
Contributor

@sayden sayden commented Jan 14, 2020

Adds Load Balancing metricset to Google Cloud Platform module.

We must take a look at the format of the distribution data that is returned by GCP in case we want to omit them as the "nature" of the lightweight module doesn't allow special modifications in the incoming data from the "engine"

c.f. #15811

@sayden sayden requested a review from a team as a code owner January 14, 2020 22:17
@sayden sayden self-assigned this Jan 14, 2020
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Nice! Only a couple of nitpicks.

- `loadbalancing.https.backend_request_count`: The number of requests served by backends of HTTP/S load balancer.
- `loadbalancing.https.backend_response_bytes_count`: The number of bytes sent as responses from backends (or cache) to HTTP/S load balancer.
- `loadbalancing.https.frontend_tcp_rtt`: A distribution of the RTT measured for each connection between client and proxy.
- `loadbalancing.https.backend_latencies`: A distribution of the latency calculated from when the request was sent by the proxy to the backend until the proxy received from the backend the last byte of response.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can sort all fields for searching purposes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, indeed. Sorted.

@@ -0,0 +1,32 @@
Load Balancing Metricset to fetch metrics from https://cloud.google.com/load-balancing/[Load Balancing] in Google Cloud Platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:s/Metricset/metricset/g

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- "loadbalancing.googleapis.com/https/backend_request_bytes_count"
- "loadbalancing.googleapis.com/https/backend_request_count"
- "loadbalancing.googleapis.com/https/backend_response_bytes_count"
- "loadbalancing.googleapis.com/https/frontend_tcp_rtt"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: please sort

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aaand sorted

Comment on lines 20 to 21
case googlecloud.ServicePubsub:
return nil, nil
case googlecloud.ServiceLoadBalancing:
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: case googlecloud.ServicePubsub, googlecloud.ServiceLoadBalancing:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 120 to 121
case googlecloud.ServicePubsub:
return
case googlecloud.ServiceLoadBalancing:
return
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: case googlecloud.ServicePubsub, googlecloud.ServiceLoadBalancing:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

case googlecloud.ServicePubsub:
return nil, nil
case googlecloud.ServiceLoadBalancing:
return nil, nil
default:
return nil, errors.Errorf("service '%s' not supported", c.ServiceName)
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about returning nil, nil by default when the service is not supported? This way you don't need to keep adding services when adding a new metricset

Copy link
Contributor

Choose a reason for hiding this comment

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

... or the other way round - nil, nil for supported services except customized ones. The code will need to be adjusted if only you need a custom call to NewMetadataService. Unsupported service will still report an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

problem with that is that the list of services is forever growing (see they are just constants we defined in our side). Every time a new service is added to stackdriver we would need to add it here, with little pay off, as this is a function to optionally enrich events when we know how to retrieve their metadata. It should do nothing for the rest.

Copy link
Contributor

@mtojek mtojek Jan 15, 2020

Choose a reason for hiding this comment

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

What do you think about such construct? The order is important, that's the only requirement, but we can cover it with unit tests:

func NewMetadataServiceForConfig(c config) (googlecloud.MetadataService, error) {
	switch c.ServiceName {
	case googlecloud.ServiceCompute:
		return compute.NewMetadataService(c.ProjectID, c.Zone, c.opt...)
	case supportedServicesAsEnum():
		return nil, nil
	default:
		return nil, errors.Errorf("service '%s' not supported", c.ServiceName)
	}
}

supportedServicesAsEnum() would read all defined constant values.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I understand what you propose. My concern comes from this scenario:

I'm happily using the stackdriver metricset with Metricbeat 7.6, I use it to monitor all my GCP services. After some time GCP adds a new service to their offering, I try to monitor it with stackdriver metricset and get this error: service 'foo' not supported. Why is it not supported if the way to collect metrics is always the same?

Then I will need to wait for the Beats team to include the service name in this enum and release a new version, then upgrade to it. All this because of how we handle metadata, which is, at the end, optional

Copy link
Contributor

@mtojek mtojek Jan 15, 2020

Choose a reason for hiding this comment

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

Agree here, but this implicates getting rid of constants at all.

EDIT:

To be clear - I'm not blocking this PR. Feel free to go!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your points. The thing was to support 3 cases here:

  • A correct / known GCP Service which is supported, having or not a specific implementation for labels (potentially we should aim to reach the highest quality and to have implementations for each metricset).
  • A correct GCP Service which is not supported: Service recognized but labelling is not supported yet. Action point -> Open enhancement request.
  • An incorrect / unknown GCP service: Service not recognized -> Action point: check service name.

The problem is that in the first PR we removed all "future metricsets" as a request and this function stay, looking naive.

One thing that is worth mention: When adding a new metricset, you don't "just" add the metrics you want to fetch. You must add the fields.yml and the docs.asciidoc and, potentially, you might add an implementation to fetch labels if the current metrics looks incomplete. I like this explicit approach where my future self will face a "metricset not recognized" while developing a new metricset if I don't pass by here to see that a labelling implementation might be needed.

I don't want to discourage comments here but this was discussed in the main module PR 😅 We can change it here but I think it must go in a different PR (because we have 3 live PR's which are using this code right now).

@sayden sayden force-pushed the feature/xp/mb/gcp/loadbalancing branch from b5b9e00 to d8ca690 Compare January 16, 2020 14:48
@andresrc andresrc requested a review from a team January 27, 2020 10:33
@sayden sayden force-pushed the feature/xp/mb/gcp/loadbalancing branch from d8ca690 to a445896 Compare February 13, 2020 19:36
@sayden sayden merged commit 978d676 into elastic:master Feb 14, 2020
@sayden sayden added the needs_backport PR is waiting to be backported to other branches. label Feb 14, 2020
sayden added a commit to sayden/beats that referenced this pull request Feb 20, 2020
kvch pushed a commit to kvch/beats that referenced this pull request Feb 20, 2020
kaiyan-sheng pushed a commit that referenced this pull request Feb 21, 2020
…to Google Cloud Platform module (#16422)

* [Metricbeat] Add Load Balancing metricset to Google Cloud Platform module (#15559)

(cherry picked from commit 978d676)

* Update changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Metricbeat Metricbeat needs_backport PR is waiting to be backported to other branches. Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants