-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor app health rules (#27) * Feature/containerHealthRules (#28) * Feature/disable node hr (#29) * microservice health rules * Merge action-suppression and port-bugfix to develop from feature b; * Add action suppression upload from file; Typos; * Add suppress action config; * Add actions folder and example file; * Dash layout Co-authored-by: alex_jov <aleksjovovic@gmail.com>
- Loading branch information
Showing
11 changed files
with
265 additions
and
8 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 |
---|---|---|
|
@@ -13,3 +13,4 @@ Setup/Applications/* | |
.vscode/* | ||
zz_demoflow* | ||
business_transactions/uploaded/* | ||
api_actions/uploaded/*.json |
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,9 @@ | ||
{ | ||
"name": "_action_suppression_name", | ||
"disableAgentReporting": true, | ||
"startTime": "_action_suppression_start", | ||
"endTime": "_action_suppression_end", | ||
"affects": { | ||
"affectedInfoType": "APPLICATION" | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"name": "CMA-suppression-tiers-nodes-test", | ||
"disableAgentReporting": true, | ||
"startTime": "2020-09-06T18:33:14+0000", | ||
"endTime": "2020-09-06T19:33:14+0000", | ||
"affects": { | ||
"affectedInfoType": "TIERS_NODES", | ||
"affectedEntities": { | ||
"tierNodeType": "NODE", | ||
"nodeType": "ALL_NODES", | ||
"affectedNodes": { | ||
"affectedNodeScope": "NODES_OF_SPECIFIC_TIERS", | ||
"specificTiers": ["Web"] | ||
} | ||
} | ||
} | ||
} |
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,68 @@ | ||
#!/bin/bash | ||
|
||
# 1. INPUT PARAMETERS | ||
_controller_url=${1} # hostname + /controller | ||
_user_credentials=${2} # ${username}:${password} | ||
|
||
_action_suppression_start=${3} | ||
_action_suppression_duration=${4} | ||
|
||
_application_name=${5} | ||
|
||
# 2. FUNCTIONS | ||
function func_check_http_response(){ | ||
local http_message_body="$1" | ||
local string_success_response_contains="$2" | ||
if [[ "$http_message_body" =~ "$string_success_response_contains" ]]; then # contains | ||
echo "Success..." | ||
else | ||
echo "${dt} ERROR "{$http_message_body}"" >> error.log | ||
echo "ERROR $http_message_body" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# 3. PREPARE REQUEST | ||
dt=$(date '+%Y-%m-%d_%H-%M-%S') | ||
|
||
_payload_path="./api_actions/uploaded/action-suppression-payload-${dt}.json" | ||
_template_path="./api_actions/action-suppression-payload-template.json" | ||
|
||
_header="Content-Type: application/json; charset=utf8" | ||
|
||
_action_suppression_name="CMA-suppression-${dt}" | ||
|
||
|
||
echo | date -d "today" >/dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
# GNU | ||
_action_suppression_end=$(date -d "${_action_suppression_start} +${_action_suppression_duration} minutes" "+%FT%T+0000") | ||
else | ||
# Mac | ||
_action_suppression_end=$(date -j -v +${_action_suppression_duration}M -f "%Y-%M-%dT%H:%M:%S+0000" "${_action_suppression_start}" "+%FT%T+0000") | ||
fi | ||
|
||
# populate the payload template | ||
sed -e "s/_action_suppression_name/${_action_suppression_name}/g" -e "s/_action_suppression_start/${_action_suppression_start}/g" -e "s/_action_suppression_end/${_action_suppression_end}/g" "${_template_path}" > "${_payload_path}" | ||
|
||
# application id | ||
allApplications=$(curl -s --user ${_user_credentials} ${_controller_url}/rest/applications?output=JSON) | ||
|
||
applicationObject=$(jq --arg appName "$_application_name" '.[] | select(.name == $appName)' <<<$allApplications) | ||
|
||
if [ "$applicationObject" = "" ]; then | ||
func_check_http_status 404 "Application '"$_application_name"' not found. Aborting..." | ||
fi | ||
|
||
application_id=$(jq '.id' <<< $applicationObject) | ||
_resource_url="alerting/rest/v1/applications/${application_id}/action-suppressions" | ||
|
||
# 4. SEND A CREATE REQUEST | ||
echo "Uploading application supression action" | ||
response=$(curl -s -X POST --user $_user_credentials $_controller_url/$_resource_url -H "${_header}" --data "@${_payload_path}" ) | ||
|
||
# 5. CHECK RESULT | ||
expected_response='"id":' # returns id on success | ||
func_check_http_response "\{$response}" $expected_response | ||
|
||
#echo "response is: $response" |
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,59 @@ | ||
#!/bin/bash | ||
|
||
# 1. INPUT PARAMETERS | ||
_controller_url=${1} # hostname + /controller | ||
_user_credentials=${2} # ${username}:${password} | ||
|
||
_application_name=${3} | ||
|
||
# 2. FUNCTIONS | ||
function func_check_http_response(){ | ||
local http_message_body="$1" | ||
local string_success_response_contains="$2" | ||
if [[ "$http_message_body" =~ "$string_success_response_contains" ]]; then # contains | ||
echo "Success..." | ||
else | ||
echo "${dt} ERROR "{$http_message_body}"" >> error.log | ||
echo "ERROR $http_message_body" | ||
#exit 1 | ||
fi | ||
} | ||
|
||
# 3. PREPARE REQUEST | ||
dt=$(date '+%Y-%m-%d_%H-%M-%S') | ||
|
||
_header="Content-Type: application/json; charset=utf8" | ||
|
||
|
||
# application id | ||
allApplications=$(curl -s --user ${_user_credentials} ${_controller_url}/rest/applications?output=JSON) | ||
|
||
applicationObject=$(jq --arg appName "$_application_name" '.[] | select(.name == $appName)' <<<$allApplications) | ||
|
||
if [ "$applicationObject" = "" ]; then | ||
func_check_http_status 404 "Application '"$_application_name"' not found. Aborting..." | ||
fi | ||
|
||
_application_id=$(jq '.id' <<< $applicationObject) | ||
_resource_url="alerting/rest/v1/applications/${_application_id}/action-suppressions" | ||
|
||
_action_suppression_files="./api_actions/actions/*.json" | ||
|
||
|
||
for f in $_action_suppression_files; do | ||
echo "Processing $f action suppression file" | ||
|
||
_payload_path=$f | ||
|
||
# 4. SEND A CREATE REQUEST | ||
response=$(curl -s -X POST --user $_user_credentials $_controller_url/$_resource_url -H "${_header}" --data "@${_payload_path}" ) | ||
|
||
# 5. CHECK RESULT | ||
expected_response='"id":' # returns id on success | ||
func_check_http_response "\{$response}" $expected_response | ||
|
||
# echo "response is: $response" | ||
|
||
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
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
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
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
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
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