-
Notifications
You must be signed in to change notification settings - Fork 486
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
Add GCP Metrics Integration #2849
Add GCP Metrics Integration #2849
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. I included some links to the Writers' Toolkit. Here's a link to the main page: https://grafana.com/docs/writers-toolkit/.
|
||
As an example, | ||
for this load balancing metric | ||
![gcp-exporter-config-metric](gcp-exporter-config-metric.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This image isn't showing up in my preview. Is it really needed? Could you link to the documentation topic rather than taking a screenshot of it? If you decide to keep the screenshot, here are guidelines: https://grafana.com/docs/writers-toolkit/writing-guide/image-guidelines/. Here's the section on where to store assets: https://grafana.com/docs/writers-toolkit/writing-guide/image-guidelines/#where-to-store-media-assets. You're supposed to use the asset uploader application and not store images locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's odd, what are you using to preview? https://github.com/grafana/agent/blob/2756dd7e62c13cb34f7a7dc70067dfcfda0c6d83/docs/sources/configuration/integrations/gcp-exporter-config.md renders it without issue.
GCP's docs aren't not really that descriptive about the three pieces of data below so I figured a screenshot breaking down what each piece means would be helpful. I can upload it if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I uploaded it let me know if it's helpful or should be removed
After deciding how the agent will obtain credentials you will need to ensure the account is set up with the IAM role `roles/monitoring.viewer`. | ||
Since the exporter gathers all of its data from GCP Monitoring APIs this is the only permission needed. | ||
|
||
## Configuration Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should include the reference section above the examples.
3ef3907
to
32a2a9c
Compare
@karengermond, I fixed up all of your doc suggestions. Thank you for the feedback, would you be able to take another pass? @marctc would it be possible to get a technical review sometime this week? Thanks. |
yes sir, tomorrow will be ready 👍 |
"golang.org/x/oauth2/google" | ||
"google.golang.org/api/monitoring/v3" | ||
"google.golang.org/api/option" | ||
"gopkg.in/yaml.v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we prefer to use v2
, for some reason v3
is giving undesired results when marshaling sometimes
} | ||
|
||
func (c *Config) Validate() error { | ||
var configErrors []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinion, but maybe is better use multierror
here?
} | ||
|
||
googleClient.Timeout = httpTimeout | ||
googleClient.Transport = rehttp.NewTransport( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look deeper, but you reckon we could use this instead? It's already in the dependencies and seems to be more popular than rehttp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it a shot like,
googleClient, err := google.DefaultClient(ctx, monitoring.MonitoringReadScope)
if err != nil {
return nil, fmt.Errorf("error creating Google client: %v", err)
}
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 4
retryClient.RetryWaitMin = time.Second
retryClient.RetryWaitMax = 5 * time.Second
retryClient.Logger = nil
googleClient.Transport = &retryablehttp.RoundTripper{Client: retryClient}
monitoringService, err := monitoring.NewService(ctx,
option.WithHTTPClient(googleClient),
)
Unfortunately, the end result seemed to disable the auth from the google.DefaultClient
😢
![gcp-exporter-config-metric-example](https://grafana.com/media/docs/agent/gcp-exporter-config-metric-example.png) | ||
|
||
The following list shows its attributes: \ | ||
monitored_resource = `https_lb_rule`\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these \
used for? github rendering is not very happy about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rehttp.RetryAll( | ||
rehttp.RetryMaxRetries(4), | ||
rehttp.RetryStatuses(http.StatusServiceUnavailable)), | ||
rehttp.ExpJitterDelay(time.Second, 5*time.Second), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @spartan0x117 if you need inspiration about the jitter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one comment but overall LGTM!
a6c7358
to
1b8fcf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Some minor edits to the code blocks in the gcp-exporter-config.md.
Co-authored-by: Karen Germond <110922559+karengermond@users.noreply.github.com>
69875a4
to
75d7f69
Compare
PR Description
Introduces a GCP metrics integration based on https://github.com/prometheus-community/stackdriver_exporter
Which issue(s) this PR fixes
Notes to the Reviewer
PR Checklist