Exporting OpenCensus data to Zenoss Cloud
Zenoss maintains libraries that enable applications instrumented with OpenCensus to export metrics to Zenoss Cloud.
- For Go applications, the OpenCensus Go Exporter.
- For JavaScript applications, a Node.js package at the NPM repository.
- For Python applications, a Python library at the Python Package Index.
To use the metrics sent through any of the preceding libraries, you must apply the policy script provided here.
Go Exporter
Zenoss maintains the opencensus-go-exporter-zenoss library to allow Go applications instrumented with OpenCensus to export metrics to Zenoss Cloud.
Installation
You can install this library into your GOPATH with the following command.
go get -u github.com/zenoss/opencensus-go-exporter-zenoss
Usage
Using the exporter requires importing the package, creating an exporter, and registering the exporter.
package main
import (
// OpenCensus packages.
"go.opencensus.io/stats/view"
// Zenoss helper for sending directly to a single API endpoint.
"github.com/zenoss/zenoss-go-sdk/endpoint"
// Zenoss OpenCensus exporter.
"github.com/zenoss/opencensus-go-exporter-zenoss/zenoss"
)
const (
ZenossAPIKey = "YOUR-API-KEY"
ZenossSource = "YOUR-APPLICATION"
)
func main() {
// Create a Zenoss API client to which we'll send metrics.
client, _ := endpoint.New(endpoint.Config{APIKey: ZenossAPIKey})
// Create Zenoss OpenCensus exporter.
exporter, _ := zenoss.NewExporter(zenoss.Options{
Output: client,
Source: ZenossSource,
})
// Register Zenoss OpenCensus exporter.
view.RegisterExporter(exporter)
// Instrument your application with OpenCensus stats.
// Flush client before exiting to send any buffered metrics.
client.Flush()
}
A complete working example can be found in the examples directory of the opencensus-go-exporter-zenoss repository.