diff --git a/gossip/metrics/metrics.go b/gossip/metrics/metrics.go new file mode 100644 index 000000000..3bf94bd2e --- /dev/null +++ b/gossip/metrics/metrics.go @@ -0,0 +1,118 @@ +/* + Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package metrics + +import ( + "sync" + + "github.com/prometheus/client_golang/prometheus" +) + +var ( + // Prometheus + // Agents + Qed_auditor_instances_count = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "qed_auditor_instances_count", + Help: "Amount of Qed_auditor agents instanciated", + }, + ) + + Qed_monitor_instances_count = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "qed_monitor_instances_count", + Help: "Amount of Qed_monitor agents instanciated", + }, + ) + + Qed_publisher_instances_count = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "qed_publisher_instances_count", + Help: "Amount of Qed_publisher agents instanciated.", + }, + ) + + Qed_auditor_batches_received_total = prometheus.NewCounter( + prometheus.CounterOpts{ + Name: "qed_auditor_batches_received_total", + Help: "Amount of batches received by Auditor.", + }, + ) + + Qed_monitor_batches_received_total = prometheus.NewCounter( + prometheus.CounterOpts{ + Name: "qed_monitor_batches_received_total", + Help: "Amount of batches received by Monitor.", + }, + ) + + Qed_publisher_batches_received_total = prometheus.NewCounter( + prometheus.CounterOpts{ + Name: "qed_publisher_batches_received_total", + Help: "Amount of batches received by Publisher.", + }, + ) + + Qed_auditor_batches_process_seconds = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "qed_auditor_batches_process_seconds", + Help: "Duration of Auditor batch processing", + }, + ) + + Qed_monitor_batches_process_seconds = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "qed_monitor_batches_process_seconds", + Help: "Duration of Monitor batch processing", + }, + ) + + Qed_publisher_batches_process_seconds = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "qed_publisher_batches_process_seconds", + Help: "Duration of Publisher batch processing", + }, + ) + + metricsList = []prometheus.Collector{ + Qed_auditor_instances_count, + Qed_monitor_instances_count, + Qed_publisher_instances_count, + + Qed_auditor_batches_received_total, + Qed_monitor_batches_received_total, + Qed_publisher_batches_received_total, + + Qed_auditor_batches_process_seconds, + Qed_monitor_batches_process_seconds, + Qed_publisher_batches_process_seconds, + } +) + +var registerMetrics sync.Once + +// Register all metrics. +func Register(r *prometheus.Registry) { + // Register the metrics. + registerMetrics.Do( + func() { + for _, metric := range metricsList { + r.MustRegister(metric) + } + }, + ) +} diff --git a/tests/start_agents b/tests/start_agents new file mode 100755 index 000000000..16c1acb95 --- /dev/null +++ b/tests/start_agents @@ -0,0 +1,62 @@ +#!/usr/bin/env sh + +# Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +qedGossipEndpoint="127.0.0.1:8400" +alertsStoreEndpoint="http://127.0.0.1:8888" +snapshotStoreEndpoint="http://127.0.0.1:8888" +qedHTTPEndpoint="http://127.0.0.1:8800" +QED="go run $GOPATH/src/github.com/bbva/qed/main.go" + +for i in `seq 1 $1`; +do + $QED agent \ + --alertsUrls $alertsStoreEndpoint \ + auditor \ + -k key \ + -l info \ + --bind 127.0.0.1:810$i \ + --join $qedGossipEndpoint \ + --qedUrls $qedHTTPEndpoint \ + --pubUrls $snapshotStoreEndpoint \ + --node auditor$i & +done + +for i in `seq 1 $2`; +do + $QED agent \ + --alertsUrls $alertsStoreEndpoint \ + monitor \ + -k key \ + -l info \ + --bind 127.0.0.1:820$i \ + --join $qedGossipEndpoint \ + --qedUrls $qedHTTPEndpoint \ + --pubUrls $snapshotStoreEndpoint \ + --node monitor$i & +done + +for i in `seq 1 $3`; +do + $QED agent \ + --alertsUrls $alertsStoreEndpoint \ + publisher \ + -k key \ + -l info \ + --bind 127.0.0.1:831$i \ + --join $qedGossipEndpoint \ + --pubUrls $snapshotStoreEndpoint \ + --node publisher$i & +done diff --git a/tests/stop_agents b/tests/stop_agents new file mode 100755 index 000000000..f770eeb02 --- /dev/null +++ b/tests/stop_agents @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +# Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +echo Cleanup... +if [ $(uname) == "Darwin" ]; then + killall agent || exit 0 +else + fuser -k -n tcp 8301 8201 8101 18301 18201 18101 || true +fi +sleep 5 +echo done. +