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
相关推荐
尽兴-3 小时前
Spring Boot 整合 Elasticsearch 8.x 实战总结(含三种实现方式 + 完整示例)
spring boot·elasticsearch·jenkins
尽兴-4 小时前
仿京东电商商品搜索服务实战:基于 Elasticsearch 的实现与落地
大数据·elasticsearch·jenkins·建模·dsl查询
逸Y 仙X5 小时前
文章十四:ElasticSearch Reindex重建索引
java·大数据·数据库·elasticsearch·搜索引擎·全文检索
雪碧聊技术5 小时前
ElasticSearch—倒排索引
大数据·elasticsearch·搜索引擎
qq_2975746715 小时前
K8s系列第十三篇:K8s 监控告警实战:Prometheus + Grafana 部署与配置
kubernetes·grafana·prometheus
ybwycx20 小时前
springboot之集成Elasticsearch
spring boot·后端·elasticsearch
@PHARAOH1 天前
WHAT - git worktree 开发的并发模型
大数据·git·elasticsearch
历程里程碑1 天前
Proto3 三大高级类型:Any、Oneof、Map 灵活解决复杂业务场景
java·大数据·开发语言·数据结构·elasticsearch·链表·搜索引擎
Elastic 中国社区官方博客1 天前
使用 TypeScript 创建 Elasticsearch MCP 服务器
大数据·服务器·数据库·人工智能·elasticsearch·搜索引擎·全文检索
逸Y 仙X1 天前
文章十三:ElasticSearch数据更新实战
java·大数据·elasticsearch·搜索引擎·jenkins