【发布时间】:2020-03-15 22:04:37
【问题描述】:
我在为应用程序的 2 个实例创建指标时遇到问题。 我使用
为 hazelcast 缓存指标创建了指标 HazelcastCacheMetrics.monitor(prometheusMeterRegistry, (IMap<?, ?>) cache.getNativeCache());
当我运行 1 个应用程序实例时一切正常,但当我运行 2 个实例时出现错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastCacheMetricConfig': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'cache_size' containing tag keys [cache, cacheManager, name]. The meter you are attempting to register has keys [cache].
或者当我将注册的指标更改为
@Autowired
private CacheMetricsRegistrar cacheMetricsRegistrar;
cacheMetricsRegistrar.bindCacheToRegistry(cache, Tag.of("instance", podName));
我有这个错误
Error creating bean with name 'hazelcastCacheMetricConfig': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'cache_size' containing tag keys [cache, cacheManager, name]. The meter you are attempting to register has keys [cache, instance, name].
感谢您帮助解决此问题
【问题讨论】:
标签: spring spring-boot prometheus metrics