最近写grafana告警配置文件的时候遇到了一个yaml格式问题
journalctl -u grafana-server -n 50 --no-pager
返回:
Error: ✗ *provisioning.ProvisioningServiceImpl run error: failure to parse file node_alert.yaml: yaml: invalid Unicode character
说明文件中有非法字符
首先看下文件是不是utf-8格式的
file -i node_alert.yaml
是的话使用python排查:
pip3 install PyYAML
python3 -c 'import yaml, sys; yaml.safe_load(open("node_alert.yaml"))'
报错的话说明文件格式有问题,使用iconv直接修复文件
yum install -y glibc-common
iconv -f utf-8 -t utf-8 -c node_alert.yaml -o node_alert_clean.yaml
在使用python看一下是否修复成功
python3 -c 'import yaml, sys; yaml.safe_load(open("node_alert_clean.yaml"))'