Sign inSign up

sjoukedv/digitalocean-billing-metricset

By sjoukedv

•Updated over 4 years ago

Retrieves DigitalOcean (preview) invoice and inserts it into Elasticsearch index

Image
0

546

sjoukedv/digitalocean-billing-metricset repository overview

⁠Environment variables

These are mandatory for the cronjob to successfully run:

  • DIGITALOCEAN_ACCESS_TOKEN
  • ELASTIC_ENDPOINT=https://elasticsearch:9200
  • ELASTIC_USERNAME=elastic
  • ELASTIC_PASSWORD=elastic
  • ELASTIC_INDEX=cloud-billing

Define in .env and run with docker run --env-file ./.env sjoukedv/digitalocean-billing-metricset:1.1

It is possible to import all the old invoices with

  • IMPORT_OLD_INVOICES=true

⁠Example document

 "_index": "cloud-billing",
  "_id": "do:volume:ams3:f31102f6-a14f-11ec-b9e7-0a58ac1482ed",
  "_version": 1,
  "_score": 1,
  "_source": {
    "product": "Kubernetes Clusters",
    "group_description": "monitoring",
    "description": "pvc-c640168a-c04e-421b-99ff-40e0e1bca6bc (ams3) - 1.0GB Volume",
    "duration": 0,
    "duration_unit": "Hours",
    "start_time": "2022-03-11T15:28:49.000Z",
    "end_time": "2022-03-11T15:52:17.000Z",
    "project_name": "default",
    "urn": "do:volume:ams3:f31102f6-a14f-11ec-b9e7-0a58ac1482ed",
    "cloud_provider": "digitalocean",
    "USD": 0.01
  },
  "fields": {
    "duration": [
      0
    ],
    "urn": [
      "do:volume:ams3:f31102f6-a14f-11ec-b9e7-0a58ac1482ed"
    ],
    "start_time": [
      "2022-03-11T15:28:49.000Z"
    ],
    "product": [
      "Kubernetes Clusters"
    ],
    "USD": [
      0.01
    ],
    "end_time": [
      "2022-03-11T15:52:17.000Z"
    ],
    "description": [
      "pvc-c640168a-c04e-421b-99ff-40e0e1bca6bc (ams3) - 1.0GB Volume"
    ],
    "cloud_provider": [
      "digitalocean"
    ],
    "project_name": [
      "default"
    ],
    "duration_unit": [
      "Hours"
    ],
    "group_description": [
      "monitoring"
    ]
  }
}

⁠Kubernetes Cron

apiVersion: batch/v1
kind: CronJob
metadata:
  name: do-billing-metrics
spec:
// equivalent to @daily
  schedule: "0 0 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: digitalocean-billing-metricset
            image: sjoukedv/digitalocean-billing-metricset:1.0
            env:
              - name: DIGITALOCEAN_ACCESS_TOKEN
                value: "...." 
              - name: ELASTIC_ENDPOINT
                value: "https://elasticsearch:9200" 
              - name: ELASTIC_USERNAME
                value: "elastic" 
              - name: ELASTIC_PASSWORD
                value: "elastic" 
              - name: ELASTIC_INDEX
                value: "cloud-billing" 

Tag summary

Content type

Image

Digest

Size

77.2 MB

Last updated

over 4 years ago

docker pull sjoukedv/digitalocean-billing-metricset:2.0