open-services / open-registry-website

Website source for https://open-registry.dev
2 stars 1 forks source link

Show finance metrics #1

Open victorb opened 5 years ago

victorb commented 5 years ago

The first version was supposed to show metrics for the registry and the finances, but ran out of time before being able to implement the backend side of things.

Uncommenting the following section should show some hardcoded values: https://github.com/open-services/open-registry-website/blob/master/index.html#L231-L345

What's missing is to have some recent hardcoded values instead of completely faked ones, so people without JS sees something.

If JS is activated, the page should hit an endpoint and parse the values to show the actual values. This could happen once every X seconds so we can updates values.

To get the metrics, there will be a GET request to something like:

# Warning: not yet implemented, hardcode in the meantime
curl 'http://metrics.open-registry.dev/api/v1/query?query=open_registry_balance'

And the response will look something like:

{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {
          "__name__": "open_registry_balance",
          "instance": "finance:6000",
          "job": "application"
        },
        "value": [
          1557142394.476,
          "21322"
        ]
      }
    ]
  }
}

The correct value to read here is 21322 and you'll need to divide by 100 to get the full value, so it's 213.22 and it's currency is EUR.

All different values for financing can be found here: https://github.com/open-services/finance-watch#examples

In the meantime, while I get the backend working, the response can be hardcoded in the website.

TODO

victorb commented 5 years ago

Metrics endpoint is now public and can be called. URL would be https://metrics.open-registry.dev/api/v1/query?query=open_registry_balance and the value can be found like this:

curl 'https://metrics.open-registry.dev/api/v1/query?query=open_registry_balance' | jq ".data.result[0].value[1]"