[blackbox exporter] server returned HTTP 400 Bad Request

154 views
Skip to first unread message

Julian Ade Putra

unread,
Aug 24, 2020, 9:47:13 AM8/24/20
to Prometheus Users
Hello,

I use blackbox exporter to monitoring API Endpoint. I able to API using json paramter and POST method manually by curl command with below result :

[weblogic@xxxxxosb04 mwteam]$ curl -d "@data.json" -X POST -H "Content-Type: application/json" http://1x.1xx.7x.x:48002/dukil/get_json/isat/call_nik
{"content":[{"NO_XX":317502141012,"NXK":324410130005,"NAME_LP":"DUMMY","AGM":"DUMMY","KAB_NAME":"DUMMY","NO_RW":"00","KEC_NAME":"DUMMY","JEN_PKRJN":"DUMMY","NO_RT":"00","ALT":"DUMMY","TMPT_LHR":"DUMMY","PDDK_AKH":"DUMMY","NM_LGKP_BU":"DUMMY","PROP_NAME":"DUMMY","KEL_NAME":"DUMMY","JNS_KLMIN":"Li Li","TGL_LER":"28-02-2018"}],"lastPage":true,"numberOfElements":1,"sort":null,"totalElements":1,"firstPage":true,"number":0,"size":1}

where is data.json :

{
    "NXK":"324410130005",
    "NO_XX":"317502141012",
    "NM_LGKP_BU":"",
    "user_id":"68317101XXXXX",
    "password":"XXXXXX",
    "msisdn":"123456789",
    "IP_User":"XXX"
}

But, when i setup in blackbox exporter with same json paramater its error - server returned HTTP status 400 Bad Request
 
Here is my configuration :

blackbox.yml :

modules:

  http_post_2xx:
    prober: http
    timeout: 5s
    http:
      valid_status_codes: [200]
      method: POST
      headers:
        Content-Type: application/json
      body: '{"NXK": "324410130005","NXK": "317502141012","NM_LGKP_BU": "","user_id": "68317101XXXXX","password": "XXXXXX","msisdn": "123456789","IP_User": "XXX"}'

prometheus.yml :

  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_post_2xx]
    static_configs:
      - targets:
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement:  xxxxxosb04:9115

Please advise if i missed something in my configuration?


Thank You!

Brian Candler

unread,
Aug 24, 2020, 11:03:31 AM8/24/20
to Prometheus Users
Firstly, your curl data includes "NO_XX":"317502141012" but your blackbox body has "NXK" twice (which is invalid JSON).

Secondly, run curl with -v so you can see the response code.  It's possible that the response code is 400 even when you get the answer you expect.

Thirdly, if that still doesn't solve the problem, then run tcpdump to capture the traffic, and compare what curl is sending with what blackbox_exporter is sending.

tcpdump -i eth0 -nn -s0 -A host 1x.1xx.7x.x and tcp port 48002

(ignore all the binary data from packet headers, and just look at the HTTP request from POST onwards).  Note also that you can test blackbox_exporter without prometheus:

curl -vg 'xxxxxosb04:9115/probe?target=http%3A%2F%2F1x.1xx.7x.x%3A48002%2Fdukil%2Fget_json%2Fisat%2Fcall_nik&module=http_post_2xx'

Reply all
Reply to author
Forward
0 new messages