创建采集任务接口
更新时间:2024-07-02
创建自定义采集任务
描述
创建CProm监控实例的自定义采集任务。
请求结构
POST /v2/scrape_job?instanceId={instanceId}&agentId={agentId} HTTP/1.1
Host: cprom.bj.baidubce.com
Authorization: authorization string
{
"config": "{config}"
}
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
---|---|---|---|---|
instanceId | String | 是 | Query参数 | Cprom监控实例ID |
agentId | String | 是 | Query参数 | Agent ID |
config | String | 是 | Body参数 | 抓取任务配置,示例值见请求示例 |
返回参数
参数名称 | 类型 | 描述 |
---|---|---|
scrapeJobId | String | 采集任务ID |
请求示例
POST /v2/scrape_job?instanceId=cprom_xxx&agentId=xxxx HTTP/1.1
Host: cprom.bj.baidubce.com
ContentType: application/json
Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2019-03-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
{
"config": "job_name: 'kubernetes-pods'\nkubernetes_sd_configs:\n - role: pod\nrelabel_configs:\n- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]\n action: replace\n target_label: __scheme__\n regex: (https?)\n- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]\n action: keep\n regex: true\n- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]\n action: replace\n target_label: __metrics_path__\n regex: (.+)\n- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]\n action: replace\n regex: ([^:]+)(?::\\d+)?;(\\d+)\n replacement: $1:$2\n target_label: __address__\n- action: labelmap\n regex: __meta_kubernetes_pod_label_(.+)\n- action: labeldrop\n regex: (.+)_revision_hash|(.+)_template_generation\n- source_labels: [__meta_kubernetes_namespace]\n action: replace\n target_label: namespace_name\n- source_labels: [__meta_kubernetes_pod_name]\n action: replace\n target_label: pod_name\n"
}
返回示例
HTTP/1.1200 OK
x-bce-request-id: 1214cca7 4ad5 451d 9215 71cb844c0a50
Date: Fri,20 May 202208:23:14 GMT
Content Type: application/json;charset=UTF-8
{
"scrapeJobId":"job-xxxx"
}