You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+13-11
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This is a Cloud Function which is used to send alerts from Google Cloud Logging
4
4
5
5
## How it Works
6
6
7
-
Some GCP infrastructure is required for this to working.
7
+
Some GCP infrastructure is required for this to work.
8
8
9
9
1.**A PubSub Topic**:<br>
10
10
Log messages will be put on this topic and trigger the Cloud Function.
@@ -50,30 +50,32 @@ This repository uses poetry. After cloning, install the dependencies by running:
50
50
poetry install
51
51
```
52
52
53
+
53
54
### Makefile
54
55
55
56
A `Makefile` is included with some useful tasks to help with development.
56
57
Running `make help` will list all available commands.
57
58
58
-
### GitHub Actions
59
-
60
-
The GitHub Actions run the linter, typechecker and tests.
59
+
### Linting and Testing
61
60
62
-
To avoid getting failures, it's worth running `make test` before commit.
63
-
Note, `make test` also runs the typechecker and linter.
61
+
The [GitHub Actions](https://docs.github.com/en/actions), a CI/CD platform, runs the linter, typechecker and tests (using workflows), whenever a GitHub PR is raised.
64
62
65
-
### Linting Errors
63
+
To minimise chances of failures when the GitHub Actions are ran, it's worth running `make test` before you push and commit to GitHub.
64
+
Note, `make test` also runs the typechecker and linter.
66
65
67
66
Linting errors can usually be fixed quickly with `make format`.
68
67
69
-
### How to silence prod alerts
68
+
69
+
### How to silence specific event logs
70
+
70
71
1. Navigate to the log entry in GCP Console and copy the entry to the clipboard
71
72
2. Create a test in the `test_main.py` file using the copied log entry
72
73
3. Run tests using `make format test` - the test you just created should fail!
73
74
4. Navigate to the `lib/filters` dir and create a new `.py` file
74
75
5. Add new functionality to the newly created file (see `osconfig_agent_filter.py` for an example)
75
76
6. Navigate to the `tests/lib/filters` dir and create a new `test_XX.py` file
76
77
7. Create unit tests that test the actual filter functionality (again, check `test_osconfig_agent_filter.py` for an example). You will need to change the fixture!
78
+
-**NB** Event logs can be difficult to replicate in a sandbox, so it is important that the unit tests are present and accurately written before it is deployed to an environment.
77
79
8. In `send_alerts.py`, import the function you just created and add it to the filter array `[]` in the `log_entry_skipped` function
9. Run `make format test` - if all pass, push it up!
87
-
88
-
**NB.**Slack alerts will only be visible in "dev", "dev-training", "preprod" and "prod"
88
+
9. Run `make format test` - if the checks pass, push and commit!
89
+
10. Deploy the Cloud Function in a sandbox and ensure it works as expected.
90
+
-**NB**Logs coming from sandboxes are filtered by default. If you want to reproduce error logs within a sandbox, make sure to remove `sandbox_filter` in `send_alerts/log_entry_skipped` before deploying the Cloud Function.
0 commit comments