Giter VIP home page Giter VIP logo

promql-cli's Introduction

nalbury

Hey folks, welcome to my github. I'm nalbury (he/him), and I spend most of my work time trying to convince kubernetes to do stuff. In my free time, I try to avoid the keyboard and get away from the machines but occasionally I work on projects here for funsies.

Generally speaking, I don't have a ton of time for maintaining these projects, but I try to add/fix stuff, respond to github issues, and review PRs when I can.

Here's some links to other cool projects:

And here's a picture of my dog: buddha

promql-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

promql-cli's Issues

better scripting support

It would be super helpful for the app to facilitate some scripting usage, such as changing exit code, when there are or aren't results. Is this in scope for this tool?

Bearer token auth not working?

Not sure if this is a bug or a feature, I can't make promql work with bearer token auth.

The following works:

$ curl  "https://prometheus.mydomain/api/v1/query?query=vector(1)" -H "Authorization: Bearer eyJra[...]udw"
{"status":"success","data":{"resultType":"vector","result":[{"metric":{},"value":[1649069401.53,"1"]}]}}

But the following doesn't (using the exact same token)

promql --host 'https://prometheus.mydomain/' --auth-type Bearer --auth-credentials 'eyJra[...]udw' 'vector(1)'                                                                                              
error querying prometheus: bad_response: readObjectStart: expect { or n, but found <, error found in #1 byte of ...|<!DOCTYPE h|..., bigger context ...|<!DOCTYPE html>     

is there some way to troubleshoot this, e.g by showing what http headers/content promql tries to send?

metrics command gets the query-error

Hello, everything work good except getting list of metrics

$ promql metrics
error querying series endpoint: bad_data: 1:1: parse error: unexpected end of input

Any suggestions? Thank you

Specify arbitrary headers when calling prometheus

In my environment, we've got prometheus fronted by a Cloudflare Access tunnel. I'd like to use promql in a script, but to do so, I would need to be able to pass a cf-access-token: XXX header. It would be useful to be able to specify whatever headers you want/need when calling prometheus.

Proxy support?

This is perhaps more a question than a bug, but I can't seem to get this utility to work against a Prometheus setup in a large corporate environment that uses corporate proxies & SSO authentication.

The Prometheus service I am trying to query has a non-SSO user account I can successfully use Basic Auth against using curl -u - I can get configuration and metric/labels manually if I can hand-wire the curl command. So I know the auth is working, and I know that curl is successfully using our HTTP_PROXY environment variables.

When I use promql here (built from source, tip of HEAD) I provide the --auth-type Basic --auth-credentials-file options where the credential file has the valid credentials. I've tried both curl -u format and | base64 formats.

The response from the tool though, looks more like a Proxy-related error:

โฏ build/bin/darwin/amd64/promql --tls_config.insecure_skip_verify  --auth-type Basic --auth-credentials-file /tmp/prom.token   --host https://prometheus.dev........... metrics
Error querying metadata endpoint: Get "https://< non-Prometheus HOST|URL that clearly indicates a redirection to our SSO service > : x509: certificate signed by unknown authority

I don't believe it's the TLS certificate error (I'm using --tls_config.insecure_skip_verify just in case) - it feels like a Proxy error.

Tracing through the Go code (not super familiar with Go though), it's using the underlying Go http library code which should auto-detect the Proxy.

I'm not sure if anyone has some further suggestions to try. Like the look of this tool!

promql v0.3.0 version actually reports v0.2.1

root@c1c30bc4b74a:/# PROMQL_VERSION=0.3.0
root@c1c30bc4b74a:/# export PROMQL_VERSION
root@c1c30bc4b74a:/# curl -L https://github.com/nalbury/promql-cli/releases/download/v${PROMQL_VERSION}/promql-v${PROMQL_VERSION}-linux-amd64.tar.gz \
  -o /tmp/promql.tar.gz \
  && tar zxf /tmp/promql.tar.gz -C /tmp/ \
  && cp -f /tmp/promql /usr/local/bin/promql \
  && chmod +x /usr/local/bin/promql
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 8121k  100 8121k    0     0  3151k      0  0:00:02  0:00:02 --:--:-- 5395k
root@c1c30bc4b74a:/# promql --version
promql version v0.2.1
root@c1c30bc4b74a:/# echo curl -L https://github.com/nalbury/promql-cli/releases/download/v${PROMQL_VERSION}/promql-v${PROMQL_VERSION}-linux-amd64.tar.gz
curl -L https://github.com/nalbury/promql-cli/releases/download/v0.3.0/promql-v0.3.0-linux-amd64.tar.gz

incorrectly tagged release?

Add support for authorization credentials

Hi @nalbury ,

First of all, thank you for this tool! It is super useful.

The Prometheus common library meanwhile supports the usage of authorization credentials (for example bearer tokens) - prometheus/common#272. It would be extremely useful to be able to use those with promql-cli.

If you don't think so, feel free to close this issue!

Christian

Windows support ๐Ÿ’

Good news is this works on windows. Just the documentation and make file is not there. I ran the below steps and it seemed to work fine.
go get
go build main.go

I am not an expert in make and make does not work well on windows anyway, but if above two statements can be added in the readme, i think that will help. I will be more than happy to raise a PR with an update to the readme.

Thanks for this great tool ๐Ÿ‘‘

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.