integrations/cAdvisor/markdown/README.en_US.md
The cadvisor collection plugin collects cadvisor data. When collecting through kubelet, it can attach pod labels and annotations.
# # collect interval
# interval = 15
[[instances]]
# Fill in the kubelet's ip and port
url = "https://1.2.3.4:10250/metrics/cadvisor"
# If the path is empty, it will be automatically completed as /metrics/cadvisor
# url = "https://1.2.3.4:10250"
# When collecting through kubelet, pod labels and annotations can be attached
type = "kubelet"
# To collect directly from cadvisor, set type to cadvisor
#url = "http://1.2.3.4:8080/metrics"
#type = "cadvisor"
# See the explanation below for how to use url_label_key and url_label_value
url_label_key = "instance"
url_label_value = "{{.Host}}"
# # Authentication token or token file
#bearer_token_string = "eyJhblonglongXXX.eyJplonglongYYY.oQsXlonglongZ-Z-Z"
bearer_token_file = "/path/to/token/file"
# Label keys to ignore
ignore_label_keys = ["id","name", "container_label*"]
# Only collect these label keys. It is recommended to leave this empty to collect all labels. Takes precedence over ignore_label_keys.
#choose_label_keys = ["*"]
timeout = "3s"
# # Optional TLS Config
# # To skip self-signed certificate verification, remember to set use_tls to true
use_tls = true
# tls_min_version = "1.2"
# tls_ca = "/etc/categraf/ca.pem"
# tls_cert = "/etc/categraf/cert.pem"
# tls_key = "/etc/categraf/key.pem"
## Use TLS but skip chain & host verification
insecure_skip_verify = true
# Extract the Host part from the URL and put it into the instance label
# Assume url = https://1.2.3.4:10250/metrics/cadvisor
# The final attached label is instance=1.2.3.4:10250
url_label_key = "instance"
url_label_value = "{{.Host}}"
If you want both the scheme part and the path part, you can write it like this:
url_label_value = "{{.Scheme}}://{{.Host}}{{.Path}}"
The related variables are generated by this method, for your reference:
func (ul *UrlLabel) GenerateLabel(u *url.URL) (string, string, error) {
if ul.LabelValue == "" {
return ul.LabelKey, u.String(), nil
}
dict := map[string]string{
"Scheme": u.Scheme,
"Host": u.Host,
"Hostname": u.Hostname(),
"Port": u.Port(),
"Path": u.Path,
"Query": u.RawQuery,
"Fragment": u.Fragment,
}
var buffer bytes.Buffer
err := ul.LabelValueTpl.Execute(&buffer, dict)
if err != nil {
return "", "", err
}
return ul.LabelKey, buffer.String(), nil
}
Taking http://1.2.3.4:8080/search?q=keyword#results as an example, the variables and their values are as follows:
| variable | value |
|---|---|
| {{.Scheme}} | http |
| {{.Host}} | 1.2.3.4:8080 |
| {{.Hostname}} | 1.2.3.4 |
| {{.Port}} | 8080 |
| {{.Path}} | search |
| {{.Query}} | q=keyword |
| {{.Fragment}} | results |