mmetrics

module
v0.0.0-...-bb39121 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2023 License: MIT

README

mmetrics

Mini-metrics service.

Overview

Development

Requirements:

  • [casey/just]
$ just

Notes

API
Decisions
  • Use Prometheus API responses as model. Overview.
    • Exposed at /api/v1/
    • support time queries as rfc3339 and unix_timestamp (ala Prometheus)
    • { status: "", data: {} }
    • values as [ ##, ## ]
  • MVP: metrics are integers

  • Exposed at /api/v1

Create new metric: POST /meta

  • params - name, desc (type??)

Add Data: POST /{:metric}

or : (like OpenTSDB)

  • params:
    • metric
    • value
    • timestamp (optional)
    • tag- 0+ k:v (optional)
  • form => single value, json=> multiple values
Getting Data

Basically, GET /query?query={:metric} w/ params corresponding to DataSetQuery interface

Also:

  • /{:metric}/last - last value
  • /{:metric}/lastUpdated

Consider multi-metric lookups (JSON only?)

POST /
Accept-encoding: application/json
{ metrics: [], query: {} }

Metric Data Responses:

Prometheus

See format overview

  • Responses are JSON:
{
  "status": "success",
  "data": specific reponse
  }

**Get list of metrics**
AKA "finding serives by label matchers":  https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers

GET /api/v1/series
  - match[] = series selector
  - start=<rfc339 | epoch>
  - end=<rfc339 | epoch>

"data" : {
  "resultType": "matrix",
  "result":[
    "metric": {
      "__name__": "name",
      "values": [
        [ ts, val ],
        [ ts, val ],
      ]
    },
  ]
}



### OpenTSDB

**Read**
http://opentsdb.net/docs/build/html/api_http/query/index.html

[ { "metric": "name", "tags": {}, "dps": [ [ts, val]... ] } ]


**Write**: 
http://opentsdb.net/docs/build/html/api_http/put

POST / { "metric": "metric name", "timestamp": , "value": 0, "tags": { "name": "value" } }

*supports multiple values via array*



### UI
HTMX - templated dashboards

### Other

* Consider a minumum resolution of 1h or 1d on timestamps to encourage
  tech-appropriate usage. I.e. if higher resolution or more metrics are needed,
  there are better solutions available.

* Consider a default order (desc) for data responses.

## License
MIT

Directories

Path Synopsis
cmd
internal
db
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL