Skip to content

Commit

Permalink
Updated github_discovery.py to add ALERTMANAGER_ENDPOINT environment …
Browse files Browse the repository at this point in the history
…variable details for testing, added enforce_admins details and updated README.md for port forward details for alertmanager (#54)
  • Loading branch information
Sandhya1874 authored Dec 5, 2024
1 parent 99af568 commit 4f96230
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,35 @@ The following secrets are required:
- **`SLACK_BOT_TOKEN`** - this uses the [`hmpps-sre-app`](https://api.slack.com/apps/A07BZTDHRNK/general) Slack app
- **`SERVICE_CATALOGUE_API_ENDPOINT`** / **`SERVICE_CATALOGUE_API_KEY`** - Service Catalogue API token
- **`SC_FILTER`** (eg. `&filters[name][$contains]=-`) - Service Catalogue filter - **required for dev**

### Port forward to redis hosted in Cloud-platform

This is useful to do so you can test changes with real alertmanager data containing slack channel information.

Create a port forward pod:

```bash
kubectl \
-n hmpps-portfolio-management-dev \
run port-forward-pod-alertmanager \
--image=ministryofjustice/port-forward \
--port=6379 \
--env="REMOTE_HOST=[Alertmanager host]" \
--env="LOCAL_PORT=6547" \
--env="REMOTE_PORT=8080"
```

Use kubectl to port-forward to it:

```bash
kubectl \
-n hmpps-portfolio-management-dev \
port-forward \
port-forward-pod-alertmanager 6574:6574
```

Ensure following redis environment variables are set:

```bash
export ALERTMANAGER_ENDPOINT='http://localhost:6574/alertmanager/status'
```
7 changes: 6 additions & 1 deletion github_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)
SC_PRODUCT_ENDPOINT = f'{SC_API_ENDPOINT}/v1/products?populate=environments{SC_PRODUCT_FILTER}{SC_PAGINATION_PAGE_SIZE}{SC_SORT}'
SC_PRODUCT_UPDATE_ENDPOINT = f'{SC_API_ENDPOINT}/v1/products'
ALERTMANAGER_ENDPOINT = 'http://monitoring-alerts-service.cloud-platform-monitoring-alerts:8080/alertmanager/status'
ALERTMANAGER_ENDPOINT = os.getenv('ALERTMANAGER_ENDPOINT','http://monitoring-alerts-service.cloud-platform-monitoring-alerts:8080/alertmanager/status')
alertmanager_json_data = ''

class HealthHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
Expand Down Expand Up @@ -443,6 +443,11 @@ def process_repo(**component):
f'branch_protection_restricted_teams: {branch_protection_restricted_teams}'
)

# Get enforce_admin details from branch protection
enforce_admins = branch_protection.enforce_admins
data.update({'github_enforce_admins_enabled': enforce_admins})
log.debug(f'github_enforce_admins_enabled: {enforce_admins}')

# Github topics
topics = repo.get_topics()
data.update({'github_topics': topics})
Expand Down

0 comments on commit 4f96230

Please sign in to comment.