我已经添加了JVM监控插件,如下所述 此处
这一切都很好,我可以,但现在我想添加更多的JMX指标,例如:MemoryPool特定的计数器。/opt/stackdriver/collectd/etc/collectd.d/jvm-sun-hotspot.conf
<MBean "jvm_localhost_MemoryPool">
ObjectName "java.lang:type=MemoryPool,name=*"
InstanceFrom "name"
<Value>
Type "gauge"
InstancePrefix "memorypool-usage_used"
Table false
Attribute "Usage.used"
</Value>
</MBean>
和
Collect "jvm_localhost_MemoryPool"
在 Connection
节
它似乎是有效的collectd配置,但当它被发送到StackdriverGoogle云监控时,它被拒绝了。
012 {#012 "index": 261,#012 "valueErrors": [#012 {#012 "error": {#012 "code": 3,#012 "message": "Unsupported
collectd id: plugin: \"jvm\" type: \"gauge\" type_instance: \"memorypool-usagecommitted\""#012 }#012 }#012 ]#012 },#012 {#012
"index": 262,#012 "valueErrors": [#012 {#012 "error": {#012 "code": 3,#012 "message": "Unsupported collectd id: plug
in: \"jvm\" type: \"gauge\" type_instance: \"memorypool-usageinit\""#012 }#012 }#012 ]#012 },#012 {#012 "index": 263,#012
"valueErrors": [#012 {#012 "error": {#012 "code": 3,#012 "message": "Unsupported collectd id: plugin: \"jvm\" type: \"gau
ge\" type_instance: \"memorypool-usagemax\""#012 }#012 }#012 ]#012 },#012 {#012 "index": 264,#012 "valueErrors": [#012
{#012 "error": {#012 "code": 3,#012 "message": "Unsupported
现在从我的理解来看,它需要被添加为一个自定义指标,但是 本文件 这表明它将被自动创建.事实上,当我看了列表中的 内置的jvm指标 我看不出它们是如何映射到collectd配置中现有的。
例如 os-open_fd_count
映射到 os/open_files
?
如果能看到Google发送的实际的api请求,将会很有帮助。定制化采集实施 但我看不到增加记录的方法。
我可以从 此职位 我想看的地方可能是自定义指标,但我如何在 collectd 配置中做到这一点?
我试过
InstancePrefix "custom.googleapis.com/memorypool-usage"
但仍然没有喜悦。
有谁以前做过这种事,或者能提供任何建议,说明我做错了什么?
故障排除文档[1]可以帮助我们确定哪些点需要转换,以及确保你的转换行为符合预期。
[1] https:/cloud.google.commonitoringagentcustom-metrics-agent#troubleshooting。
为了得到这个日志,我需要添加 stackdriver_metric_type
元数据。
完整的链条现在是
<Chain "GenericJMX_jvm">
<Rule "rewrite_custom_jmx">
<Match regex>
Plugin "^GenericJMX$"
PluginInstance "^jvm.*$"
TypeInstance "^memorypool-usage_used$"
</Match>
<Target "set">
MetaData "stackdriver_metric_type" "custom.googleapis.com/jvm/memorypool/usage_used"
MetaData "label:pool" "%{plugin_instance}"
</Target>
<Target "replace">
MetaData "label:pool" "jvm" ""
</Target>
</Rule>
<Rule "rewrite_genericjmx_to_jvm">
<Match regex>
Plugin "^GenericJMX$"
PluginInstance "^jvm.*$"
</Match>
<Target "replace">
PluginInstance "jvm" ""
</Target>
<Target "set">
Plugin "jvm"
</Target>
Target "return"
</Rule>
</Chain>
插件实例是池名(例如G1 Eden Space),这就是为什么我把它复制到'池'标签中。
这确实在Stackdriver中自动创建了度量,但我也使用了下面的体例。project.metricDescriptors.create 方法来添加描述和单位。
{
"name": "projects/yourprojecthere/metricDescriptors/custom.googleapis.com/jvm/memorypool/usage_used",
"labels": [
{
"key": "pool",
"description": "Name of the JVM memory pool."
}
],
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"unit": "By",
"description": "Current size in bytes of the memory pool.",
"type": "custom.googleapis.com/jvm/memorypool/usage_used",
"monitoredResourceTypes": [
"gce_instance"
]
}