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
相关推荐
Elastic 中国社区官方博客15 分钟前
根据用户行为数据中的判断列表在 Elasticsearch 中训练 LTR 模型
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
风清再凯3 小时前
04_es原理&filebeat使用
大数据·elasticsearch·搜索引擎
补三补四9 小时前
Git 基础操作指南
大数据·git·elasticsearch
Aubrey-J11 小时前
Linux中快速部署Elasticsearch(基础&TLS配置)
linux·服务器·elasticsearch
Elasticsearch11 小时前
Elasticsearch:创建一个定制的 DeepSeek 嵌入推理端点
elasticsearch
风清再凯13 小时前
02_ES索引规范&kibana
大数据·elasticsearch·搜索引擎
失散1317 小时前
分布式专题——46 ElasticSearch高级查询语法Query DSL实战
java·分布式·elasticsearch·架构
Elasticsearch17 小时前
Elasticsearch 推理 API 增加了开放的可定制服务
elasticsearch
麦麦麦造1 天前
小小 Postgres,何以替代 Redis、MongoDB 甚至 ES?
redis·mongodb·elasticsearch·postgresql
Zzz 小生1 天前
Claude Code学习笔记(四)-助你快速搭建首个Python项目
大数据·数据库·elasticsearch