-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to sync AlertManager configuration with Cortex #10
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution @RyanW8! Looking good so far, a couple of small changes and a question.
@@ -13,6 +13,8 @@ This action is configured using environment variables defined in the workflow. T | |||
| `CORTEX_API_KEY` | Optional password that is required for password protected Cortex clusters. An encrypted [github secret](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets ) is recommended. | `false` | N/A | | |||
| `ACTION` | Which action to take. One of `lint`, `prepare`, `check`, `diff` or `sync` | `true` | N/A | | |||
| `RULES_DIR` | Comma-separated list of directories to walk in order to source rules files | `false` | `./` | | |||
| `COMPONENT` | `RULER` or `ALERTMANAGER`. This dictates whether to sync ruler rulegroups or AlertManager configurations | `true` | N/A | | |||
| `ALERTMANAGER_CONFIG_PATH` | Path to the tenants AlertManager configuration | `true` If `COMPONENT` is set to `ALERTMANAGER` | `./alertManager.yml` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's missing a |
at the end, in the diff, it looks like one column instead of two - am I missing something?
if [ -z "${RULES_DIR}" ]; then | ||
echo "RULES_DIR not set, using './' as a default." | ||
RULES_DIR="./" | ||
fi | ||
|
||
if [ ${COMPONENT} == "ALERTMANAGER" ] && [ -z "${ALERTMANAGER_CONFIG_PATH}" ]; then | ||
echo "No ALERTMANAGER_CONFIG_PATH variable set. Defaulting to ./alertManager.yml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "No ALERTMANAGER_CONFIG_PATH variable set. Defaulting to ./alertManager.yml" | |
echo "ALERTMANAGER_CONFIG_PATH not set, using ./alertmanager.yml as a default." |
if [ -z "${RULES_DIR}" ]; then | ||
echo "RULES_DIR not set, using './' as a default." | ||
RULES_DIR="./" | ||
fi | ||
|
||
if [ ${COMPONENT} == "ALERTMANAGER" ] && [ -z "${ALERTMANAGER_CONFIG_PATH}" ]; then | ||
echo "No ALERTMANAGER_CONFIG_PATH variable set. Defaulting to ./alertManager.yml" | ||
ALERTMANAGER_CONFIG_PATH=./alertManager.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ALERTMANAGER_CONFIG_PATH=./alertManager.yml | |
ALERTMANAGER_CONFIG_PATH=./alertmanager.yml |
echo "COMPONENT not set, select either RULER or ALERTMANAGER" | ||
exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "COMPONENT not set, select either RULER or ALERTMANAGER" | |
exit 1 | |
echo "COMPONENT not set, using RULER as a default." | |
COMPONENT=RULER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make sure we do not break existing setups.
;; | ||
esac | ||
elif [ "${COMPONENT}" == "ALERTMANAGER" ]; then | ||
OUTPUT=$(/usr/bin/cortextool alertmanager load ${ALERTMANAGER_CONFIG_PATH}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have time to add the other commands just like the previous block?
;; | ||
esac | ||
elif [ "${COMPONENT}" == "ALERTMANAGER" ]; then | ||
OUTPUT=$(/usr/bin/cortextool alertmanager load ${ALERTMANAGER_CONFIG_PATH}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OUTPUT=$(/usr/bin/cortextool alertmanager load ${ALERTMANAGER_CONFIG_PATH}) | |
verifyTenantAndAddress | |
OUTPUT=$(/usr/bin/cortextool alertmanager load ${ALERTMANAGER_CONFIG_PATH}) |
OUTPUT=$(/usr/bin/cortextool alertmanager load ${ALERTMANAGER_CONFIG_PATH}) | ||
STATUS=$? | ||
else | ||
echo "Invalid component selected, use RULER or ALERTMANAGER" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "Invalid component selected, use RULER or ALERTMANAGER" | |
echo "COMPONENT is not valid, please use RULER or ALERTMANAGER." |
STATUS=$? | ||
;; | ||
$PRINT_CMD) | ||
OUTPUT=$(/usr/bin/cortextool rules print "$@") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OUTPUT=$(/usr/bin/cortextool rules print "$@") | |
verifyTenantAndAddress | |
OUTPUT=$(/usr/bin/cortextool rules print "$@") |
RyanW8 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
No description provided.