Skip to content

Commit

Permalink
fix: fixed README.md and get_status function
Browse files Browse the repository at this point in the history
  • Loading branch information
payaljindal committed Mar 12, 2024
1 parent 7f4e8e6 commit 258928f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions tools/target-server-validator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Validation is done by deploying a sample proxy which check if HOST & PORT is ope
## Pre-Requisites
* Python3.x
* Java
* Maven
3.9.6
* Maven >= 3.9.6
* Please install the required Python dependencies
```
python3 -m pip install -r requirements.txt
Expand Down Expand Up @@ -52,7 +51,7 @@ api_ip=<IP> # IP address corresponding to a
report_format=csv # Report Format. Choose csv or md (defaults to md)
[gcp_metrics]
enable_gcp_metrics=true # set 'true' to push target server's host and status to stack driver
enable_gcp_metrics=true # set 'true' to push target server's host and status to GCP metrics
project_id=xxx-xxx-xxx # Project id of GCP project where the data will be pushed
metric_name=custom.googleapis.com/<metric_name> # Replace <metric_name> with custom metric name
enable_dashboard=true # set 'true' to create the dashboard with alerting policy
Expand Down Expand Up @@ -174,4 +173,8 @@ Please check a [Sample report](report.md)
## GCP Monitoring Dashboard
The script can also create a GCP Monitoring Dashboard with an alerting widget like shown below:

![GCP Monitoring Dashboard](images/dashboard.png)
![GCP Monitoring Dashboard](images/dashboard.png)

This script creates a custom metric with labels as hostname and status. The possible statuses, namely REACHABLE NOT_REACHABLE, and UNKNOWN_HOST, are determined by calling the validator proxy. These statuses are then assigned values of 1, 0.5, and 0, respectively.

Then, an alerting policy is created with a threshold of 0.75. Entries below this threshold trigger alerts sent to designated notification channels. Finally, this policy is added as a widget on the GCP dashboard.
4 changes: 2 additions & 2 deletions tools/target-server-validator/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def create_custom_metric(project_id, metric_name):
return None


def get_status_int(status):
def get_status_value(status):
if status == "REACHABLE":
return 1
elif status == "NOT_REACHABLE":
Expand Down Expand Up @@ -339,7 +339,7 @@ def report_metric(project_id, metric_descriptor, sample_data):

try:
for data in sample_data:
point = monitoring_v3.Point({'interval': interval, 'value': {'double_value': get_status_int(data[5])}}) # noqa
point = monitoring_v3.Point({'interval': interval, 'value': {'double_value': get_status_value(data[5])}}) # noqa
series.metric.labels['hostname'] = data[2]
series.metric.labels['status'] = data[5]
series.points = [point]
Expand Down

0 comments on commit 258928f

Please sign in to comment.