Giter Club home page Giter Club logo

prometheus-query-js's Issues

unexpected http error

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?

Incompatible with node v17

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'
}

Getting unexpected_error when trying to query Prometheus

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?

Add more details to `unexpected client error` error handling

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',
            };

Typescript support?

Hey
Can you please publish types package? It will be really helpful for typescript users :)

Thanks!

alerts() returns undefined for state

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:

ResponseType[obj['state']],

You may have intended for that to reference TargetState?

export type TargetState = 'active' | 'dropped' | 'any';

and if so TargetState should also include 'firing' and 'pending'

cheers!

Errors of Prometheus are not handled

My problem

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).

image

Question

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.

Refused to set unsafe header "Accept-Encoding"

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?)

link github on npm

hey thanks for the repo. ๐Ÿ‘
Would be nice if you could link this github repo on npm as it is not easily found.

How to set the rate interval in the PROMQL similar to $__rate_interval by grafana.

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,
> }

Does this package support Request interceptor?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.