quazardous/munin-solr-metrics

SolR Metrics 统计 Munin 插件

1.0.6 2018-10-21 08:15 UTC

This package is auto-updated.

Last update: 2024-09-23 07:37:01 UTC


README

Munin 插件使用(新的)SolR Metrics API。

https://lucene.apache.org/solr/guide/7_5/metrics-reporting.html

安装

git clone(推荐)

cd /opt
git clone https://github.com/quazardous/munin-solr-metrics.git
cd munin-solr-metrics/
composer install

或者 composer 本地

composer require quazardous/munin-solr-metrics

或者 composer global

composer global require quazardous/munin-solr-metrics

注意:不鼓励以 root 身份使用 composer

使用方法

将软件链接到 munin 插件

(cd /etc/munin/plugins/; ln -s /opt/munin-solr-metrics/bin/munin_solr_metrics solr_metrics)

这将使用默认配置文件。

您可以使用特定的配置文件

(cd /etc/munin/plugins/; ln -s /opt/munin-solr-metrics/bin/munin_solr_metrics solr_metrics_my_profile)

这将使用配置文件中的 my_profile(见下文)。

配置文件

位置

插件将按照以下顺序搜索配置文件

  • 环境变量 MUNIN_SOLR_METRICS_CONFIG 指定的文件
  • ./.munin-solr-metrics.php
  • $HOME/.munin-solr-metrics.php
  • /etc/munin-solr-metrics.php

注意:您可以通过添加插件配置文件 /etc/munin/plugin-conf.d/solr_metrics 来注入环境变量。

[solr_metrics*]
#user solr
env.MUNIN_SOLR_METRICS_CONFIG /path/to/munin-solr-metrics.php
timeout 30

结构

配置文件是一个返回配置数组的 PHP 文件。

<?php

return [
   // First level elements are profiles.
   // Each profile will produce a multigraph plugin.
   'default' => [
   	 // You have to define the SolR Metrics API query
       'solr_metrics_query' => 'https://:8983/solr/admin/metrics',
       // You can use any query parameters. Be aware that some parameters can change the response structure and affect the metric definitions below.
       // 'solr_metrics_query' => 'https://:8983/solr/admin/metrics?group=core',
       //'solr_auth' => 'user:password', // the plugin can handle basic auth
       'graphs' => [
           // each graph element will produce a munin graph entry.
           'graph1' => [
               'fields' => [
                   '2xx' => [
                       // You can target any existing metric
                       // Use `|` (pipe) to create a metric path. 
                       'metric' => 'solr.jetty|org.eclipse.jetty.server.handler.DefaultHandler.2xx-responses|count',
                       // Any othe attribute will be added as field attribute to the munin graph config.
                       'draw' => 'LINE', // will produce `_2xx.draw LINE`
                   ],
                   '2xx.1minRate' => [
                       'metric' => 'solr.jetty|org.eclipse.jetty.server.handler.DefaultHandler.2xx-responses|1minRate',
                   ],
                   'error' => [
                       'metric' => [
                           // if metric is an array, metrics will be aggregated
                           'solr.jetty|org.eclipse.jetty.server.handler.DefaultHandler.4xx-responses|count',
                           'solr.jetty|org.eclipse.jetty.server.handler.DefaultHandler.5xx-responses|count',
                       ],
                       // by default metrics are added together but you can specify your own function, metrics are passed by arg in order
                       // 'metric_aggregate' => function ($metric1, $metric2) { return $metric1 + $metric2; }, 
                   ],
               ],
               // Any other attributes will be added to the munin graph config.
               'graph_category' => 'solr',
               'graph_info' => 'Something meaningful',
           ],
       ]
   ],
];

查看 contrib\examples 目录以获取更多示例。