Stackdriver-agent没有收集监控数据(KeyRache的HitRate)

时间:2018-02-19 14:32:33

标签: cassandra collectd google-cloud-stackdriver

我正在GCE VM中配置Stackdriver-agent来监控Cassandra指标。 (基于GCP指南:https://cloud.google.com/monitoring/agent/plugins/cassandra

我使用了上面链接的默认设置,它们运行正常。 但是,我添加的一个指标不适用于以下错误。

我为Type和Value或Count for Attribute尝试了计量器或计数器。但是,它们中的任何一个都不能很好地工作。

请提出任何建议。

  • 错误
      

    Feb 19 23:14:08 pgxxxxxxx1 collectd [16917]:write_gcm:服务器响应(CollectdTimeseriesRequest)包含错误:                                              {                                                “payloadErrors”:[                                                  {                                                    “index”:161,                                                    “valueErrors”:[                                                      {                                                        “错误”:{                                                          “代码”:3,                                                          “message”:“不支持的collectd id:plugin:\”cassandra \“type:\”gauge \“type_instance:\”cache_key_cache-hitrate \“”                                                        }                                                      }                                                    ]                                                  }                                                ]                                              }

Config(将KeyCache-Hitrate指标添加到指南中的原始配置中)

  • 连接部分:

    <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部分:

    <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>
    

我的环境  stackdriver-agent 5.5.2-379.sdl.stretch  cassandra 3.11.1

1 个答案:

答案 0 :(得分:1)

遵循自定义指标指南,我可以解决我的问题。

  1. 创建自定义指标 按照此处的指南进行操作:https://cloud.google.com/monitoring/custom-metrics/creating-metrics#monitoring-create-metric-python (从自定义度量标准名称直到调用create方法。不需要时间序列)
  2. 还需要获得授权才能访问监控。 (按照IAM指南)。

    1. 配置cassandra插件(.conf文件) 指南:https://cloud.google.com/monitoring/agent/custom-metrics-agent (从顶部直到加载新配置)
    2. 我的示例代码

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

        来自google.cloud导入监控

        client = monitoring.Client() descriptor = client.metric_descriptor(     'custom.googleapis.com/cassandra/client_request/latency/1minrate',     metric_kind = monitoring.MetricKind.GAUGE,     VALUE_TYPE = monitoring.ValueType.DOUBLE,     labels = [monitoring.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>
        
      3. 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监控手册的官方指南不易阅读和理解。 我希望这会有所帮助..

相关问题