black box exporter post api issue for content type application./json

41 views
Skip to first unread message

Suresh Mallampati

unread,
May 18, 2020, 11:35:23 AM5/18/20
to Prometheus Users
Hi ,
      I am using the below yaml files for testing the post api using black box exorter.
expected result is  
probe_http_status_code value 200 the same thing checked using postman.
but i am getting probe_http_status_code value 415



blackbox. yml

http_post_2xx:
    prober: http
    http:
      method: POST
      headers:
        Content-Type: application/json;
      body: '{aaaa: "355987085036738",status: "Active"}

prometheus.yml
       - job_name: 'checkpost'
    scrape_interval: 45s
    metrics_path: /probe
    params:
      module: [http_post_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - http://xxx.yyy/create
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115  # Blackbox exporter.

Brian Candler

unread,
May 18, 2020, 12:05:20 PM5/18/20
to Prometheus Users
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415

Perhaps it doesn't like your Content-Type with trailing semicolon?  Also, the body you've given is not valid JSON:

body: '{aaaa: "355987085036738",status: "Active"}
--->
body: '{"aaaa": "355987085036738","status": "Active"}'

I'd suggest the easiest way to debug this is to use "curl" interactively until you can find a series of options that works, and then you can translate that into blackbox_exporter configuration.

Another thing you can do is to use tcpdump to capture the response from the remote webserver when blackbox_exporter scrapes it.  It may include text in the response body which explains the problem with the request.  Something like this (adjust the interface name as necessary):
tcpdump -i eth0 -nn -s0 -A host xxx.yyy and tcp port 80


Suresh Mallampati

unread,
May 20, 2020, 6:28:13 AM5/20/20
to Prometheus Users
Thank you very much .
After doing the  corrections also i am facing the same issue . If there is any sample or document could helpful for me.

Suresh Mallampati

unread,
May 20, 2020, 6:35:42 AM5/20/20
to Prometheus Users
If any one can help using the api  http://dummy.restapiexample.com/create sample prometheus.yml,blackbox.yml files for http post

Suresh Mallampati

unread,
May 20, 2020, 6:47:37 AM5/20/20
to Prometheus Users
yes the example is working . I need to check with the api provider
http_post_2xx:
    prober: http
    http:
      method: POST
      headers:
        Content-Type: application/json
      body: '{"name":"test","salary":"123","age":"23"}'
    scrape_interval: 45s
    metrics_path: /probe
    params:
      module: [http_post_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115  # Blackbox exporter.
thank you for the help
Reply all
Reply to author
Forward
0 new messages