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

Export OpenCensus metrics to Stackdriver #118

Merged
merged 1 commit into from
Apr 12, 2019
Merged

Export OpenCensus metrics to Stackdriver #118

merged 1 commit into from
Apr 12, 2019

Conversation

knyar
Copy link
Contributor

@knyar knyar commented Apr 10, 2019

Currently OpenCensus metrics are only exposed to Prometheus for scraping. This adds a flag that also makes them reported to Stackdriver.

CC @jkohen who owns #8 this is probably related to.

@jkohen jkohen self-requested a review April 10, 2019 14:31
Copy link
Contributor

@jkohen jkohen left a comment

Choose a reason for hiding this comment

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

Thanks! Note that before we can close #8, we need to replace all Prometheus client metrics with OpenCensus. E.g.

succeededSamplesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "succeeded_samples_total",
Help: "Total number of samples successfully sent to remote storage.",
},
[]string{queue},
)
failedSamplesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "failed_samples_total",
Help: "Total number of samples which failed on send to remote storage.",
},
[]string{queue},
)
droppedSamplesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "dropped_samples_total",
Help: "Total number of samples which were dropped due to the queue being full.",
},
[]string{queue},
)
sentBatchDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "sent_batch_duration_seconds",
Help: "Duration of sample batch send calls to the remote storage.",
Buckets: prometheus.DefBuckets,
},
[]string{queue},
)
queueLength = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "queue_length",
Help: "The number of processed samples queued to be sent to the remote storage.",
},
[]string{queue},
)
queueCapacity = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "queue_capacity",
Help: "The capacity of the queue of samples to be sent to the remote storage.",
},
[]string{queue},
)
numShards = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "shards",
Help: "The number of shards used for parallel sending to the remote storage.",
},
[]string{queue},
)

That means that this PR will only get you select metrics into Stackdriver. If this is an issue for you, we'd appreciate the feedback on issue #8. I think we should find the time to make the change now that OpenCensus supports gauges idiomatically.

cmd/stackdriver-prometheus-sidecar/main.go Outdated Show resolved Hide resolved
@knyar
Copy link
Contributor Author

knyar commented Apr 10, 2019

That means that this PR will only get you select metrics into Stackdriver.

That's exactly what I'd like to achieve. I am working on another PR that will add a few OpenCensus metrics, so just wanted to make sure there's a way to get them reported to Stackdriver, not just Prometheus.

@@ -228,6 +230,8 @@ func main() {
a.Flag("prometheus.api-address", "Address to listen on for UI, API, and telemetry.").
Default("http://127.0.0.1:9090/").URLVar(&cfg.prometheusURL)

a.Flag("stackdriver.enable-internal-metrics", "Whether to report Sidecar metrics to Stackdriver").Default("false").BoolVar(&cfg.sdOpencensus)
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 want to be too picky about this, but the flag name is unclear. I'd call it something like monitoring.backend and make the default value "prometheus" and have "stackdriver" as optional. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that's a good idea. Renamed to --monitoring.backend.

@jkohen jkohen merged commit a9aa4eb into Stackdriver:master Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants