» npm install prometheus-query
Prometheus provides an ability to query data with PromQL via /api/v1/query and /api/v1/query_range HTTP APIs.
If you need querying raw samples for some time series matching the given series selectors on a specified time range (t-d ... t], then the following query to /api/v1/query HTTP API can be issued:
curl 'http://prometheus-host:9090/api/v1/query?query=some_series_selector[d]&time=t`
For example, http://demo.robustperception.io:9090/api/v1/query?query=up[5m]
See this article for details.
Prometheus is not RDBMS, and does not provide similar openness of it's enternal structure. You as a user are not supposed to know how data is stored internally. Data structure used is rigid, and does not intend any user intervention/tinkering/optimization.
If you really want to know how data is stored, Prometheus has a open source code, so you are free to investigate it to find all the details you want, but I don't see any benefit in that: considering the fact that Prometheus only stores scraped metric, I don't think there is much to investigate there.
Regarding querying data I don't see any benefit to knowing how data is stored, since you are still expected to use promQL, that doesn't allow any kind of query modifications with hints, plan optimizations and such.
Although you might try using Grafana's Explore feature: it has autosuggestion for metric names, labels and other syntax sugar of that nature. This might ease your learning curve a bit.
requests_failed_total and on(service) requests_processed_total > 1000
https://prometheus.io/docs/prometheus/latest/querying/operators/#logical-set-binary-operators https://prometheus.io/docs/prometheus/latest/querying/operators/#one-to-one-vector-matches
If you are using Grafana you can do the following:
(1) Create a dashboard
(2) Click on Dashboard settings > Variables > New
(3) Create a variable with the following:
Name = service
Type = Query
Data source = Prometheus
Query = query_result(request_processed_total>5)
Regex = /service="(.*)"/
(4) Use the "service" variable to show the "requests_failed_total" metrics in any panel (you can also use the "repeat for " Grafana feature.