请问修改了categraf配置中的hostname 但程序启动后还是去读取了主机的hostname,为啥启动的时候没有重新加载配置

Viewed 54



请问修改了categraf配置中的hostname 但程序启动后还是去读取了主机的hostname,为啥启动的时候没有重新加载配置

3 Answers

重启服务了吗

重启过的

填一下自己的配置截图

配置如下

[global]

whether print configs

print_configs = true

add label(agent_hostname) to series

"" -> auto detect hostname

"xx" -> use specified string xx

"$hostname" -> auto detect hostname

"$ip" -> auto detect ip

"$hostname-$ip" -> auto detect hostname and ip to replace the vars

hostname = "test190"

will not add label(agent_hostname) if true

omit_hostname = true

s | ms

precision = "ms"

global collect interval

interval = 15

input provider settings; optional: local / http

providers = ["local"]

disable_usage_report = true

[global.labels]

region = "shanghai"

env = "localhost"

[log]

file_name is the file to write logs to

file_name = "/home/categraf-v0.2.37-linux-amd64/stdout"

options below will not be work when file_name is stdout or stderr

max_size is the maximum size in megabytes of the log file before it gets rotated. It defaults to 100 megabytes.

max_size = 100

max_age is the maximum number of days to retain old log files based on the timestamp encoded in their filename.

max_age = 1

max_backups is the maximum number of old log files to retain.

max_backups = 1

local_time determines if the time used for formatting the timestamps in backup files is the computer's local time.

local_time = true

Compress determines if the rotated log files should be compressed using gzip.

compress = false

[writer_opt]
batch = 1000
chan_size = 1000000

[[writers]]
url = "http://192.168.30.199:17000/prometheus/v1/write"

Basic auth username

basic_auth_user = ""

Basic auth password

basic_auth_pass = ""

Optional headers

headers = ["X-From", "categraf", "X-Xyz", "abc"]

timeout settings, unit: ms

timeout = 5000
dial_timeout = 2500
max_idle_conns_per_host = 100

[http]
enable = false
address = ":9100"
print_access = false
run_mode = "release"

[ibex]
enable = false

ibex flush interval

interval = "1000ms"

n9e ibex server rpc address

servers = ["127.0.0.1:20090"]

temp script dir

meta_dir = "./meta"

[heartbeat]
enable = true

report os version cpu.util mem.util metadata

url = "http://192.168.30.199:17000/v1/n9e/heartbeat"

interval, unit: s

interval = 10

Basic auth username

basic_auth_user = ""

Basic auth password

basic_auth_pass = ""

Optional headers

headers = ["X-From", "categraf", "X-Xyz", "abc"]

timeout settings, unit: ms

timeout = 5000
dial_timeout = 2500
max_idle_conns_per_host = 100

卧槽兄弟你用markdown code段包括一下,这看着真头疼

runner.hostname 读取的是本机的 hostname,并不是读取的配置里的hostname,这个符合预期。你通过 ./categraf --test --inputs mem 可以看到输出的指标中的 agent_hostname 标签,那个标签的值才是配置里的 hostname 的值

好的 明白了,期初以为设备列表里不更新子节点状态是因为hostname重复导致的,现在看来不是,那这个问题就解决了,还请您移步另外一个问题=。=《设备列表中手动删除的机器,如何重新注册回来?》