GithubHelp home page GithubHelp logo

Comments (3)

yunlzheng avatar yunlzheng commented on May 11, 2024

原生支持的http_basic认证,如下:

http_basic_auth_example:
    prober: http
    timeout: 5s
    http:
      method: POST
      headers:
        Host: "login.example.com"
      basic_auth:
        username: "username"
        password: "mysecret"

如果不支持http basic,也可以考虑在headers中传递token之类的方式。

from prometheus-book.

tianxinliang123 avatar tianxinliang123 commented on May 11, 2024

我的blackbox.yml的配置:如下

modules: 
  http_basic_auth_eureka:
    prober: http
    timeout: 50s
    http:
      preferred_ip_protocol: "ip4"
      #valid_status_codes: [200,301]
      method: POST
      headers:
        Host: "192.168.11:11:8888"
        Cache-Control: no-cache
        #Content-Type: application/xhtml+xml
        Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
      basic_auth:
        username: 'eureka'
        password: '********'

浏览器输入http://192.168.11.10:9115/probe?module=http_basic_auth_eureka&target=192.168.11.11:8888&debug=true
返回的结果

Logs for the probe:
ts=2018-10-14T13:44:05.812604029Z caller=main.go:116 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Beginning probe" probe=http timeout_seconds=9.5
ts=2018-10-14T13:44:05.812991876Z caller=utils.go:42 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Resolving target address" preferred_ip_protocol=ip4
ts=2018-10-14T13:44:05.813048814Z caller=utils.go:65 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Resolved target address" ip=192.168.11.11
ts=2018-10-14T13:44:05.813133583Z caller=http.go:282 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Making HTTP request" url=http://192.168.11.11:8889 host=192.168.11:11:8888
ts=2018-10-14T13:44:05.815049201Z caller=http.go:300 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Received HTTP response" status_code=400
ts=2018-10-14T13:44:05.815126856Z caller=http.go:315 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Invalid HTTP response status code, wanted 2xx" status_code=400
ts=2018-10-14T13:44:05.815197566Z caller=http.go:354 module=http_basic_auth_eureka target=192.168.11.11:8889 level=info msg="Response timings for roundtrip" roundtrip=0 start=2018-10-14T21:44:05.81340103+08:00 dnsDone=2018-10-14T21:44:05.81340103+08:00 connectDone=2018-10-14T21:44:05.813792176+08:00 gotConn=2018-10-14T21:44:05.813820583+08:00 responseStart=2018-10-14T21:44:05.814958826+08:00 end=2018-10-14T21:44:05.815028447+08:00
ts=2018-10-14T13:44:05.815457064Z caller=main.go:129 module=http_basic_auth_eureka target=192.168.11.11:8889 level=error msg="Probe failed" duration_seconds=0.00269175

返回的http code 为400,我的username和password是正确了,那里出问题了?大佬

from prometheus-book.

yunlzheng avatar yunlzheng commented on May 11, 2024

并没返回403的错误码,400是Bad Request。 检查一下你服务的日志呢

from prometheus-book.

Related Issues (20)

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.