From c8e30aa4c87c06eb693924a892d9f79cd12eaa1a Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 12 Jul 2018 19:18:35 +0200 Subject: [PATCH] Add more metrics to the solr exporter configuration. --- solr/tasks/main.yml | 1 + solr/templates/solr-exporter-config.xml | 170 ++++++++++++++++++++++++ 2 files changed, 171 insertions(+) diff --git a/solr/tasks/main.yml b/solr/tasks/main.yml index cbe8b989..cf80b528 100644 --- a/solr/tasks/main.yml +++ b/solr/tasks/main.yml @@ -70,6 +70,7 @@ - name: Install the Solr prometheus exporter config file template: src=solr-exporter-config.xml dest={{ solr_prometheus_conf_file }} mode=0644 notify: Restart Solr prometheus exporter + tags: [ 'solr', 'solr_prometheus', 'solr_prometheus_exporter', 'solr_prometheus_exporter_config' ] - name: Install the Solr prometheus exporter upstart script template: src=solr_prometheus_exporter.upstart.j2 dest=/etc/init/solr_prometheus_exporter.conf mode=0644 owner=root group=root diff --git a/solr/templates/solr-exporter-config.xml b/solr/templates/solr-exporter-config.xml index b043835e..66dc8650 100644 --- a/solr/templates/solr-exporter-config.xml +++ b/solr/templates/solr-exporter-config.xml @@ -1636,6 +1636,176 @@ } end + + .metrics | to_entries | .[] | select(.key | startswith("solr.core.")) as $parent | + $parent.key | split(".") as $parent_key_items | + $parent_key_items | length as $parent_key_item_len | + (if $parent_key_item_len == 3 then $parent_key_items[2] else "" end) as $core | + (if $parent_key_item_len == 5 then $parent_key_items[2] else "" end) as $collection | + (if $parent_key_item_len == 5 then $parent_key_items[3] else "" end) as $shard | + (if $parent_key_item_len == 5 then $parent_key_items[4] else "" end) as $replica | + (if $parent_key_item_len == 5 then ($collection + "_" + $shard + "_" + $replica) else $core end) as $core | + $parent.value | to_entries | .[] | select(.key | endswith(".requestTimes")) | select (.value | type == "object") as $object | + $object.key | split(".")[0] as $category | + $object.key | split(".")[1] as $handler | + select($handler | startswith("/")) | + $object.value.meanRate as $value | + if $parent_key_item_len == 3 then + { + name: "solr_metrics_core_requests_meanrate_seconds", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core"], + label_values: [$category, $handler, $core], + value: $value + } + else + { + name: "solr_metrics_core_requests_meanrate", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core", "collection", "shard", "replica"], + label_values: [$category, $handler, $core, $collection, $shard, $replica], + value: $value + } + end + + + .metrics | to_entries | .[] | select(.key | startswith("solr.core.")) as $parent | + $parent.key | split(".") as $parent_key_items | + $parent_key_items | length as $parent_key_item_len | + (if $parent_key_item_len == 3 then $parent_key_items[2] else "" end) as $core | + (if $parent_key_item_len == 5 then $parent_key_items[2] else "" end) as $collection | + (if $parent_key_item_len == 5 then $parent_key_items[3] else "" end) as $shard | + (if $parent_key_item_len == 5 then $parent_key_items[4] else "" end) as $replica | + (if $parent_key_item_len == 5 then ($collection + "_" + $shard + "_" + $replica) else $core end) as $core | + $parent.value | to_entries | .[] | select(.key | endswith(".requestTimes")) | select (.value | type == "object") as $object | + $object.key | split(".")[0] as $category | + $object.key | split(".")[1] as $handler | + select($handler | startswith("/")) | + $object.value."1minRate" as $value | + if $parent_key_item_len == 3 then + { + name: "solr_metrics_core_requests_1minrate_seconds", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core"], + label_values: [$category, $handler, $core], + value: $value + } + else + { + name: "solr_metrics_core_requests_1minrate", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core", "collection", "shard", "replica"], + label_values: [$category, $handler, $core, $collection, $shard, $replica], + value: $value + } + end + + + .metrics | to_entries | .[] | select(.key | startswith("solr.core.")) as $parent | + $parent.key | split(".") as $parent_key_items | + $parent_key_items | length as $parent_key_item_len | + (if $parent_key_item_len == 3 then $parent_key_items[2] else "" end) as $core | + (if $parent_key_item_len == 5 then $parent_key_items[2] else "" end) as $collection | + (if $parent_key_item_len == 5 then $parent_key_items[3] else "" end) as $shard | + (if $parent_key_item_len == 5 then $parent_key_items[4] else "" end) as $replica | + (if $parent_key_item_len == 5 then ($collection + "_" + $shard + "_" + $replica) else $core end) as $core | + $parent.value | to_entries | .[] | select(.key | endswith(".requestTimes")) | select (.value | type == "object") as $object | + $object.key | split(".")[0] as $category | + $object.key | split(".")[1] as $handler | + select($handler | startswith("/")) | + $object.value."5minRate" as $value | + if $parent_key_item_len == 3 then + { + name: "solr_metrics_core_requests_5minrate_seconds", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core"], + label_values: [$category, $handler, $core], + value: $value + } + else + { + name: "solr_metrics_core_requests_5minrate", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core", "collection", "shard", "replica"], + label_values: [$category, $handler, $core, $collection, $shard, $replica], + value: $value + } + end + + + .metrics | to_entries | .[] | select(.key | startswith("solr.core.")) as $parent | + $parent.key | split(".") as $parent_key_items | + $parent_key_items | length as $parent_key_item_len | + (if $parent_key_item_len == 3 then $parent_key_items[2] else "" end) as $core | + (if $parent_key_item_len == 5 then $parent_key_items[2] else "" end) as $collection | + (if $parent_key_item_len == 5 then $parent_key_items[3] else "" end) as $shard | + (if $parent_key_item_len == 5 then $parent_key_items[4] else "" end) as $replica | + (if $parent_key_item_len == 5 then ($collection + "_" + $shard + "_" + $replica) else $core end) as $core | + $parent.value | to_entries | .[] | select(.key | endswith(".requestTimes")) | select (.value | type == "object") as $object | + $object.key | split(".")[0] as $category | + $object.key | split(".")[1] as $handler | + select($handler | startswith("/")) | + $object.value."15minRate" as $value | + if $parent_key_item_len == 3 then + { + name: "solr_metrics_core_requests_15minrate", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core"], + label_values: [$category, $handler, $core], + value: $value + } + else + { + name: "solr_metrics_core_requests_15minrate_seconds", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core", "collection", "shard", "replica"], + label_values: [$category, $handler, $core, $collection, $shard, $replica], + value: $value + } + end + + + .metrics | to_entries | .[] | select(.key | startswith("solr.core.")) as $parent | + $parent.key | split(".") as $parent_key_items | + $parent_key_items | length as $parent_key_item_len | + (if $parent_key_item_len == 3 then $parent_key_items[2] else "" end) as $core | + (if $parent_key_item_len == 5 then $parent_key_items[2] else "" end) as $collection | + (if $parent_key_item_len == 5 then $parent_key_items[3] else "" end) as $shard | + (if $parent_key_item_len == 5 then $parent_key_items[4] else "" end) as $replica | + (if $parent_key_item_len == 5 then ($collection + "_" + $shard + "_" + $replica) else $core end) as $core | + $parent.value | to_entries | .[] | select(.key | endswith(".requestTimes")) | select (.value | type == "object") as $object | + $object.key | split(".")[0] as $category | + $object.key | split(".")[1] as $handler | + select($handler | startswith("/")) | + $object.value.mean_ms / 1000 as $value | + if $parent_key_item_len == 3 then + { + name: "solr_metrics_core_requests_mean_time_seconds", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core"], + label_values: [$category, $handler, $core], + value: $value + } + else + { + name: "solr_metrics_core_requests_mean_time_seconds", + type: "GAUGE", + help: "See following URL: https://lucene.apache.org/solr/guide/metrics-reporting.html", + label_names: ["category", "handler", "core", "collection", "shard", "replica"], + label_values: [$category, $handler, $core, $collection, $shard, $replica], + value: $value + } + end +