-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|