samber / prometheus-query-js Goto Github PK
View Code? Open in Web Editor NEW๐ A Javascript client for Prometheus query API
Home Page: https://www.npmjs.com/package/prometheus-query
License: MIT License
๐ A Javascript client for Prometheus query API
Home Page: https://www.npmjs.com/package/prometheus-query
License: MIT License
Curl ok, postman ok but this library return
{
"error": {
"status": "error",
"errorType": "unexpected_error",
"error": "unexpected http error"
},
"status": "success"
}
What the F.U.C.K was this guyโs problem?
Hi!
As you know http://demo.robustperception.io:9090/ is using HTTP and causes some issues in examples due to that.
May I suggest you use the official demo site instead; https://prometheus.demo.do.prometheus.io in this repository and chartjs-plugin-datasource-prometheus?
Library works perfectly with node v16.14.2
but returns this error in v17.8.0
.
Unknown error {
status: 'error',
errorType: 'unexpected_error',
error: 'unexpected http error'
}
I just spent some time trying to figure why I cannot use this library to query my Prometheus instance.
Look like for newest Prometheus version (I'm running 2.25.2), the gzip encoding is required.
This is what worked for me:
const promDriver = new PrometheusDriver({
endpoint: "http://localhost:9090",
baseURL: "/api/v1",
headers: {
'Accept-Encoding': 'gzip'
},
warningHook: (x => console.log(x))
});
This issue is more for future people who might face the same issue - maybe worth adding something on the readme?
prometheus-query-js/src/index.js
Line 50 in da7f4b0
prometheus-query-js/src/index.js
Line 51 in da7f4b0
In the PrometheusQuery.request
function, the username and password is taken from the this.proxy
member variable. Shouldn't these parameters be taken from this.auth
instead?
I'm getting unexpected client error
when running instantQuery
.
But I don't know what to do. The error doesn't happen for all resources but happens all the time for the same resources but as the error is not detailed I can't understand what is happening. Is it possible improve this code below to expose more details?
throw {
status: 'error',
errorType: 'client_error',
error: 'unexpected client error',
};
It would be great if the prometheus-query-js would be able to push data to Prometheus-like databases such as VictoriaMetrics. It may push data via any supported data ingestion protocol. The most straightforward protocol for js is JSON import or OpenTSDB HTTP /put protocol, which is also based on JSON.
Hey
Can you please publish types package? It will be really helpful for typescript users :)
Thanks!
First, thanks for the library, this is great!
I noticed when pulling prom.alerts() that our alert state is always coming back undefined (rather than 'firing' or 'pending').
I'm not confident enough to try a patch and PR but I think this is a mixed array call:
prometheus-query-js/src/types.ts
Line 229 in f1a2776
You may have intended for that to reference TargetState?
prometheus-query-js/src/types.ts
Line 299 in f1a2776
and if so TargetState should also include 'firing' and 'pending'
cheers!
I execute the query "sensor_1 @ 1234567" , resulting in the following request:
GET /query?query=sensor_1+%40+123456&time=1647448589.845
If I look to the raw response that Prometheus gives me, this is that I obtain:
{
"status":"error",
"errorType":"bad_data",
"error":"@ modifier is disabled"
}
However, in my Angular project, the prometheus-query library does not seem to handle the case where there is an error as above (see screenshot below).
I think this is a problem of the library itself, as I said. Can someone confirm this and tell me how I can resolve this ? Thank you.
How to use a jwt as auth?
Hi,
I am using your https://github.com/samber/chartjs-plugin-datasource-prometheus and I keep seeing these console error messages:
Refused to set unsafe header "Accept-Encoding"
(anonymous) @ prometheus-query.umd.js:7
u @ prometheus-query.umd.js:7
(anonymous) @ prometheus-query.umd.js:7
x @ prometheus-query.umd.js:7
N @ prometheus-query.umd.js:7
Promise.then (async)
C.request @ prometheus-query.umd.js:7
(anonymous) @ prometheus-query.umd.js:7
request @ prometheus-query.umd.js:7
rangeQuery @ prometheus-query.umd.js:7
(anonymous) @ prometheus-query.umd.js:7
executeQueries @ prometheus-query.umd.js:7
beforeUpdate @ prometheus-query.umd.js:7
notify @ Chart.min.js:7
update @ Chart.min.js:7
afterInit @ prometheus-query.umd.js:7
notify @ Chart.min.js:7
initialize @ Chart.min.js:7
construct @ Chart.min.js:7
Qe @ Chart.min.js:7
(anonymous) @ chart.html:16
Could this have been introduced by #11 ?
Would it be possible to allow /not/ setting this variable (or default to not setting it?)
hey thanks for the repo. ๐
Would be nice if you could link this github repo on npm as it is not easily found.
I am trying to fetch the different metrics using PROMQL and make my custom dashboard similar to grafana. But I am not sure how to dynamically set rate interval and step in query range using the given time range.
I am using HTTP API provided by the Prometheus.
> const rateInterval = "5m"; **//need to make this dynamic according to the given time range.**
> const queryRangeList = {
> load15: `node_load15`,
> cpuUsage: `sum by(instance) (irate(node_cpu_seconds_total{instance="localhost:9100",job="node", mode="system"}[${rateInterval}])) / on(instance) group_left sum by (instance)((irate(node_cpu_seconds_total{instance="localhost:9100",job="node"}[${rateInterval}])))`,
> memoryUsage: `node_memory_MemTotal_bytes{instance="localhost:9100",job="node"} - node_memory_MemFree_bytes{instance="localhost:9100",job="node"} - (node_memory_Cached_bytes{instance="localhost:9100",job="node"} + node_memory_Buffers_bytes{instance="localhost:9100",job="node"} + node_memory_SReclaimable_bytes{instance="localhost:9100",job="node"})`,
> };
>
> module.exports = {
> queryRangeList,
> }
The rangeQuery method only accepts a numeric parameter for step.
step=<duration | float>: Query resolution step width **in duration format or** float number of seconds.
The duration format is a string, and can go as low as 1ms
.
Hi,
Thanks to this project & your contribution! When I introduce this package to our product, I find that we have some QueryString needed when calling Prometheus.
Just want to know, if this package supports Request Interceptor?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.