Git Product home page Git Product logo

go-opentelemetry-proves's Introduction

go-opentelemetry-proves

Releases

There is a problem with v0.11.0 and so go.mod contains:

github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.11.1-0.20200910093037-ef5e24b7fcfc

Run

Requires a Project with Cloud Monitoring enabled and a service account with roles/monitoring.admin

So:

PROJECT="dazwilkin-$(date +%y%m%d)-opentelemetry"
BILLING=$(gcloud alpha billing accounts list --format="value(name)")
ACCOUNT="stackdriver"

gcloud projects create ${PROJECT}
gcloud beta billing projects link ${PROJECT} --billing-account=${BILLING}

gcloud services enable monitoring.googleapis.com --project=${PROJECT}

gcloud iam service-accounts create ${ACCOUNT} \
--project=${PROJECT}

gcloud iam service-accounts keys create ${PWD}/${ACCOUNT}.json  \
--iam-account=${ACCOUNT}@${PROJECT}.iam.gserviceaccount.com \
--project=${PROJECT}

gcloud projects add-iam-policy-binding ${PROJECT} \
--member=serviceAccount:${ACCOUNT}@${PROJECT}.iam.gserviceaccount.com \
--role=roles/monitoring.admin

Perhaps then: https://console.cloud.google.com/monitoring/signup?project=${PROJECT}

Interestingly, there's a new gcloud monitoring dashboards create ....

So:

gcloud monitoring dashboards create \
--config-from-file=${PWD}/dashboard.json \
--project=${PROJECT}

DASHBOARD=$(gcloud monitoring dashboards list \
--filter="displayName=OpenTelemetry" \
--format="value(name.basename())" \
--project=${PROJECT}) && echo ${DASHBOARD}

Then:

https://console.cloud.google.com/monitoring/dashboards/custom/${DASHBOARD}?project=${PROJECT}

Finally:

GOOGLE_APPLICATION_CREDENTIALS=${PWD}/${ACCOUNT}.json \
PROJECT=${PROJECT} \
go run github.com/DazWilkin/go-opentelemetry-prove

Yields:

2020/09/11 11:24:51 [main] ProjectID: dazwilkin-200911-opentelemetry
2020/09/11 11:25:01 [main] v=69
2020/09/11 11:25:11 [main] v=12
2020/09/11 11:25:21 [main] v=75
2020/09/11 11:25:31 [main] v=10
2020/09/11 11:25:41 [main] v=38
2020/09/11 11:25:51 [main] v=56
2020/09/11 11:26:01 [main] v=73
2020/09/11 11:26:11 [main] v=68
2020/09/11 11:26:21 [main] v=79
2020/09/11 11:26:31 [main] v=17

And:

Cloud Monitoring

APIs Explorer

curl \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Accept: application/json" \
"https://monitoring.googleapis.com/v3/projects/${PROJECT}/metricDescriptors?filter=metric.type%3D%22custom.googleapis.com%2Fopentelemetry%2Fcounter.foo%22"
{
  "metricDescriptors": [
    {
      "name": "projects/dazwilkin-200911-opentelemetry/metricDescriptors/custom.googleapis.com/opentelemetry/counter.foo",
      "labels": [
        {
          "key": "dog"
        },
        {
          "key": "lemons"
        },
        {
          "key": "key"
        }
      ],
      "metricKind": "CUMULATIVE",
      "valueType": "INT64",
      "description": "Auto-created custom metric.",
      "type": "custom.googleapis.com/opentelemetry/counter.foo",
      "monitoredResourceTypes": [
        ...
        "global",
        ...
      ]
    }
  ]
}

And:

TODAY=$(date +'%Y-%m-%d')
curl \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Accept: application/json" \
"https://monitoring.googleapis.com/v3/projects/${PROJECT}/timeSeries?filter=metric.type%3D%22custom.googleapis.com%2Fopentelemetry%2Fcounter.foo%22&interval.endTime=${TODAY}T23%3A59%3A59Z&interval.startTime=${TODAY}T00%3A00%3A00Z"
{
  "timeSeries": [
    {
      "metric": {
        "labels": {
          "lemons": "test",
          "key": "value",
          "dog": "Freddie"
        },
        "type": "custom.googleapis.com/opentelemetry/counter.foo"
      },
      "resource": {
        "type": "global",
        "labels": {
          "project_id": "dazwilkin-200911-opentelemetry"
        }
      },
      "metricKind": "CUMULATIVE",
      "valueType": "INT64",
      "points": [
        {
          "interval": {
            "startTime": "2020-09-11T18:24:51Z",
            "endTime": "2020-09-11T22:01:51Z"
          },
          "value": {
            "int64Value": "64441"
          }
        },
        {
          "interval": {
            "startTime": "2020-09-11T18:24:51Z",
            "endTime": "2020-09-11T22:00:51Z"
          },
          "value": {
            "int64Value": "64180"
          }
        },
        {
          "interval": {
            "startTime": "2020-09-11T18:24:51Z",
            "endTime": "2020-09-11T21:59:51Z"
          },
          "value": {
            "int64Value": "63811"
          }
        },
        {
          "interval": {
            "startTime": "2020-09-11T18:24:51Z",
            "endTime": "2020-09-11T21:58:51Z"
          },
          "value": {
            "int64Value": "63541"
          }
        },
        {
          "interval": {
            "startTime": "2020-09-11T18:24:51Z",
            "endTime": "2020-09-11T21:57:51Z"
          },
          "value": {
            "int64Value": "63311"
          }
        },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.