0

I'm configuring Stackdriver-agent in GCE VM to monitor Cassandra metrics. (based on GCP guide: https://cloud.google.com/monitoring/agent/plugins/cassandra)

I used the default setting of the link above, and they work fine. However, one metric I added doesn't work with the following error.

I tried gauge or counter for Type and Value or Count for Attribute. However, either of them doesn't work well.

Any suggestion, please.

  • Error

    Feb 19 23:14:08 pgxxxxxxx1 collectd[16917]: write_gcm: Server response (CollectdTimeseriesRequest) contains errors: { "payloadErrors": [ { "index": 161, "valueErrors": [ { "error": { "code": 3, "message": "Unsupported collectd id: plugin: \"cassandra\" type: \"gauge\" type_instance: \"cache_key_cache-hitrate\"" } } ] } ] }

Config (added KeyCache-Hitrate metrics to the original config in the guide)

  • Connection part:

    <Connection>
    # When using non-standard Cassandra configurations, replace the below with
    #ServiceURL "service:jmx:rmi:///jndi/rmi://CASSANDRA_HOST:CASSANDRA_PORT/jmxrmi"
    ServiceURL "service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi"
    InstancePrefix "cassandra"
    User "cassandra"
    Password "xxxxxxxx"
    Collect "cassandra_storageservice-load"
    Collect "cassandra_Cache_KeyCache-Hits"
    Collect "cassandra_Cache_KeyCache-HitRate"   <===== Added line
    ...
    Collect "cassandra_DroppedMessage_MUTATION-Dropped"
    Collect "cassandra_DroppedMessage_READ-Dropped"
    

  • MBean part:

    <MBean "cassandra_Cache_KeyCache-HitRate">
        ObjectName "org.apache.cassandra.metrics:type=Cache,scope=KeyCache,name=HitRate"
        <Value>
            Type "gauge"
            InstancePrefix "cache_key_cache-hitrate"
            Table false
            Attribute "Value"
        </Value>
    </MBean>
    

My environment stackdriver-agent 5.5.2-379.sdl.stretch cassandra 3.11.1

4

1 回答 1

1

按照自定义指标指南和 ,我可以解决我的问题。

  1. 创建自定义指标遵循此处的指南:https : //cloud.google.com/monitoring/custom-metrics/creating-metrics#monitoring-create-metric-python(从自定义指标名称直到调用创建方法。时间序列不是必需的)

也需要被授权才能访问监控。(遵循 IAM 指南)。

  1. 在此处配置 cassandra 插件(.conf 文件)指南:https ://cloud.google.com/monitoring/agent/custom-metrics-agent (从顶部到加载新配置)

我的示例代码

  1. 创建自定义指标的代码 client_request_read-latency-1minrate.py

    从 google.cloud 导入监控

    client = monitoring.Client() 描述符 = client.metric_descriptor('custom.googleapis.com/cassandra/client_request/latency/1minrate', metric_kind=monitoring.MetricKind.GAUGE, value_type=monitoring.ValueType.DOUBLE, labels=[监控。 label.LabelDescriptor("operation", description="存储操作名称。")], description='Cassandra 1分钟读取延迟率', display_name='读取延迟1分钟率') descriptor.create()

  2. cassandra 插件示例(在同一个配置文件中遵循 2-1 和 2-2) 2-1. cassandra 插件示例第 1 部分

     <MBean "cassandra_custom_ClientRequest_Read-Latency">
         ObjectName "org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Latency"
         <Value>
             Type "gauge"
             InstancePrefix "client_request_read-latency-1minrate"
             Table false
             Attribute "OneMinuteRate"
         </Value>
     </MBean>
    
    <Connection>
        # When using non-standard Cassandra configurations, replace the below with
        #ServiceURL "service:jmx:rmi:///jndi/rmi://CASSANDRA_HOST:CASSANDRA_PORT/jmxrmi"
        ServiceURL "service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi"
        InstancePrefix "cassandra_custom"
        User "cassandra user name"
        Password "your password"
    
        Collect "cassandra_custom_ClientRequest_Read-Latency"
    </Connection>
    

2-2。cassandra 插件示例第 2 部分

<Chain "GenericJMX_cassandra_custom">
    <Rule "rewrite_genericjmx_to_cassandra_custom">
        <Match regex>
            Plugin "^GenericJMX$"
            PluginInstance "^cassandra_custom.*$"
        </Match>
        <Target "set">
            MetaData "stackdriver_metric_type" "custom.googleapis.com/cassandra/client_request/latency/1minrate"
            MetaData "label:operation" "%{plugin_instance}"
        </Target>
        <Target "replace">
            MetaData "label:operation" "cassandra_custom_" ""
        </Target>
    </Rule>
    <Rule "go_back">
        Target "return"
    </Rule>
</Chain>

<Chain "PreCache">
    <Rule "jump_to_GenericJMX_cassandra_custom">
        <Target "jump">
            Chain "GenericJMX_cassandra_custom"
        </Target>
    </Rule>
</Chain>
PreCacheChain "PreCache"

Stackdriver 监控手册的官方指南不易阅读和理解。我希望这个能帮上忙..

于 2018-02-22T03:36:16.307 回答