elasticsearch_exporter启动报错 failed to fetch and decode node stats

最近把服务器迁移到了ubuntu系统,结果发现在centos还正常运行的elasticsearch_exporter,用systemd启动后一直报错 failed to fetch and decode node stats

在网上翻了大半年,竟然都无解!这种报错,很明显就是你的ES密码中有特殊字符导致的,但问题是如何解决呢?比如ES是密码是abc#

如果elasticsearch_exporter.service 这么写,就报错了

bash 复制代码
[Service]
User=root
Nice=10
ExecStart=/var/kingdee/elasticsearch_exporter/elasticsearch_exporter --es.uri "http://elastic:abc#@1.1.1.1:9200"
ExecStop=/bin/pkill elasticsearch_exporter
Restart=on-failure

想了各种办法,比如加引号,加\,都是徒劳。终于偶然看到这个:

原来是需要用URL加密才行啊!

于是在站长工具,如此即可

于是结果是 abc%23 ,这就完了吗,没有!发现报另外的错误: Failed to resolve unit specifiers in http://XXXXXX: Invalid slot

起因就是%符号,在systemd是有固定涵义的,所以需要转义,不是加\,而是再加一个%

于是,正确的姿势是这样的:

bash 复制代码
[Service]
User=root
Nice=10
ExecStart=/var/kingdee/elasticsearch_exporter/elasticsearch_exporter --es.uri "http://elastic:abc%%23@1.1.1.1:9200"
ExecStop=/bin/pkill elasticsearch_exporter
Restart=on-failure
相关推荐
李@十一₂⁰2 小时前
git多分支管理
大数据·git·elasticsearch
johnnyAndCode5 小时前
ES迁移工具,纯手搓,灵活好用效率高
大数据·elasticsearch·搜索引擎
flying robot8 小时前
Prometheus[2.33.3]grafana[12.3.1]监控安装
grafana·prometheus
予枫的编程笔记9 小时前
深度解析Kibana:从基础到进阶的全维度数据可视化指南
java·人工智能·elasticsearch·kibana
Galaxy~5679 小时前
Git常见命令及用法
大数据·git·elasticsearch
dessler9 小时前
Elasticsearch(ES)备份与快照(Snapshot)
大数据·elasticsearch·jenkins
CoderJia程序员甲9 小时前
Python连接和操作Elasticsearch详细指南
python·elasticsearch
铭毅天下9 小时前
投标环节:如何科学、合理地介绍 Elasticsearch 国产化替代方案——Easysearch?
大数据·elasticsearch·搜索引擎·全文检索
Elasticsearch9 小时前
使用 Elastic Agent Builder 和 MCP 实现 Agentic 参考架构
elasticsearch
yumgpkpm10 小时前
Cloudera CDH5、CDH6、CDP7现状及替代方案
数据库·人工智能·hive·hadoop·elasticsearch·数据挖掘·kafka