Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Custom StackDriver Monitoring Metrics on Dataproc #1808

Closed
shsunil11 opened this issue Mar 22, 2019 · 7 comments
Closed

Custom StackDriver Monitoring Metrics on Dataproc #1808

shsunil11 opened this issue Mar 22, 2019 · 7 comments
Assignees

Comments

@shsunil11
Copy link

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

0.19.2

What JVM are you using (java -version)?

1.8.0._171

What did you do?

If possible, provide a recipe for reproducing the error.

Tested the example code on a Dataproc cluster master node.
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/opencensus/src/main/java/com/example/opencensus/Quickstart.java

The Dataproc Cluster had a service account tied to it that had the Project Editor Role.
The scopes used for the Dataproc Cluster was 'https://www.googleapis.com/auth/cloud-platform'

Also tried to use the project_id in the builder as described in
https://github.com/census-instrumentation/opencensus-java/tree/master/exporters/stats/stackdriver

StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration.builder().setProjectId("MyStackdriverProjectId").build());

What did you expect to see?

Expected to see the custom metrics in the Stackdriver Monitoring Workspace in the Metrics Explorer under resource type Global

What did you see instead?

The custom metrics did not show up in the Metrics Explorer

@songy23
Copy link
Contributor

songy23 commented Mar 22, 2019

The issue here is main thread exited before data got exported. The QuickStart used the default export interval which is 60s while main thread also waited 60s before exiting. This is a bit risky since it took a bit time to upload metrics to Stackdriver.

Two quick way to make the sample work:

  1. Make the main thread wait a bit longer, e.g change EXPORT_INTERVAL to 65s or greater.
  2. Configure the Stackdriver exporter to export more frequently by using StackdriverStatsConfiguration. For example StackdriverStatsConfiguration.builder().setExportInterval(TEN_SECONDS).build(). Note in real production Stackdriver recommended the export interval to be at least 1 minute.

@yzhou2001
Copy link

It works now with the 60->70 seconds change

@songy23
Copy link
Contributor

songy23 commented Mar 22, 2019

Thanks @yzhou2001 for the confirmation. I'm going to mark this as resolved for now, please feel free to follow up if you've seen other issues.

@songy23 songy23 closed this as completed Mar 22, 2019
@ocervell
Copy link

ocervell commented Mar 22, 2019

@shsunil11 nice to see it's finally working !
@songy23 can we document this export interval ? sounds like a gotcha

@yzhou2001
Copy link

While the sleep solves the issue, I'm wondering whether there is a "flushing" mechanism to force out the collected data to the StackDriver backend. As for applications, it's often undesirable to be forced to sleep a period, in particular for low-latency and/or chained apps.

@yzhou2001
Copy link

One more clarification: the resource type is not "Global" but "GCE VM Instance" somehow.

@songy23
Copy link
Contributor

songy23 commented Mar 22, 2019

can we document this export interval ? sounds like a gotcha

Yes, we'll add this to opencensus.io. Tracked in census-instrumentation/opencensus-website#652.

I'm wondering whether there is a "flushing" mechanism to force out the collected data to the StackDriver backend. As for applications, it's often undesirable to be forced to sleep a period, in particular for low-latency and/or chained apps.

Agree. There's a spec issue on supporting this: census-instrumentation/opencensus-specs#152.

One more clarification: the resource type is not "Global" but "GCE VM Instance" somehow.

If the application and exporter is running on a GCE instance, this will be captured by the resource detection util and the metrics uploaded to Stackdriver will have a GCE instance resource associated. See more details at https://github.com/census-instrumentation/opencensus-java/tree/master/exporters/stats/stackdriver#set-monitored-resource-for-exporter.

mtabasko added a commit to mtabasko/java-docs-samples that referenced this issue Apr 4, 2019
Increase "EXPORT_INTERVAL" from 60 seconds to 70 seconds, to work around census-instrumentation/opencensus-java#1808. (Otherwise, metrics do not actually get exported to Stackdriver.)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants