Project: HertzBeat (Observability and Analysis / Observability)
File: extend-http.md

id: extend-http title: HTTP Protocol Custom Monitoring sidebar_label: HTTP Protocol Custom Monitoring From , you are familiar with how to customize types, Metrics, protocols, etc. Here we will introduce in detail how to use HTTP protocol to customize Metric monitoring Call HTTP API->Response Verification->Parse Response Data->Default method parsingJsonPath script parsing | XmlPath parsing(todo) | Prometheus parsing->Metric data extraction It can be seen from the process that we define a monitoring type of HTTP protocol. We need to configure HTTP request parameters, configure which Metrics to obtain, and configure the parsing method and parsing script for response data. HTTP protocol supports us to customize HTTP request path, request header, request parameters, request method, request body, etc. System default parsing methodHTTP interface returns the JSON data structure specified by hertzbeat, that is, the default parsing method can be used to parse the data and extract the corresponding Metric data. For details, refer to JsonPath script parsing methodUse JsonPath script to parse the response JSON data, return the data structure specified by the system, and then provide the corresponding Metric data. For details, refer to HertzBeat Dashboard -> Monitoring Templates -> New Template -> Config Monitoring Template Yml -> Save and Apply -> Add A Monitoring with The New Monitoring Type Configuration usages of the monitoring templates yml are detailed below. Please pay attention to usage annotation. We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring. Monitoring template is used to define the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information, etc. egDefine a custom monitoring type `app` named `example_http` which use the HTTP protocol to collect data. Monitoring Templates -> Config New Monitoring Template Yml -> Save and Apply ```yaml category: custom app: example_http name: zh-CN: en-US: EXAMPLE APP params: field: host name: zh-CN: Host en-US: Host type: host required: true field: port name: zh-CN: en-US: Port type: number range: '[0,65535]' required: true defaultValue: 80 placeholder: 'Please enter the port' field: username name: zh-CN: en-US: Username type: text limit: 20 required: false field: password name: zh-CN: en-US: Password type: password required: false field: ssl name: zh-CN: SSL en-US: Enable SSL type: boolean required: false field: method name: zh-CN: en-US: Method type: radio required: true options: label: GET request value: GET label: POST request value: POST label: PUT request value: PUT label: DELETE request value: DELETE metrics: name: cpu priority: 0 fields: field: hostname type: 1 label: true field: usage type: 0 unit: '%' field: cores type: 0 field: waitTime type: 0 unit: s aliasFields: hostname core1 core2 usage allTime runningTime calculates: hostname=hostname cores=core1+core2 usage=usage waitTime=allTime-runningTime protocol: http http: host: ^^host^^ port: ^^port^^ url: /metrics/cpu method: GET ssl: false headers: apiVersion: v1 params: param1: param1 param2: param2 authorization: type: Basic Auth basicAuthUsername: ^^username^^ basicAuthPassword: ^^password^^ parseType: jsonPath parseScript: '$' name: memory priority: 1 fields: field: hostname type: 1 label: true field: total type: 0 unit: kb field: usage type: 0 unit: '%' field: speed type: 0 protocol: http http: host: ^^host^^ port: ^^port^^ url: /metrics/memory method: GET headers: apiVersion: v1 params: param1: param1 param2: param2 authorization: type: Basic Auth basicAuthUsername: ^^username^^ basicAuthPassword: ^^password^^ parseType: default ```