prometheus-community / json_exporter

A prometheus exporter which scrapes remote JSON by JSONPath
Apache License 2.0
633 stars 197 forks source link

Adding fonctionality to support cookie for secure sites authentication #159

Open pmeffre opened 2 years ago

pmeffre commented 2 years ago

Is there a way to add the support of cookie file in the request header?

The cURL request must look like that: curl 'https://172.17.101.150/rest/v1/banner/post_auth' -H 'Cookie: id=550orR9UL-Q3yBx4IWOwNQ==; user=eyJ1c2VyIjoiYWRtaW4iLCJsZXZlbCI6MTUsInR5cGUiOiJMT0NBTCIsIm1ldGhvZCI6IkxPQ0FMIn0=' The cookie is is obtained via first login URL(user/password in POST): https://172.17.101.150/rest/v1/login

Thank you

SuperQ commented 2 years ago

This is already possible via headers in the config file.

pmeffre commented 2 years ago

Hi Thank you Could you give me a sample how to code that with a cookie file as input ? Regards,

Pierre

DaBeOps commented 2 years ago

Hi, I have the same problem and there is no clear information about it. Anyone can give an example if it works with "headers"?

rustycl0ck commented 2 years ago

Could you give me a sample how to code that with a cookie file as input ?

You can set (static) custom header values in the config, but the value of the header can not be read from an external file.

thewangcj commented 10 months ago

i add cookies like this:

  headers:
    Cookie: "session=xxxxxxxxxx"