Skip to content

Commit

Permalink
chore: Update README.md (#489)
Browse files Browse the repository at this point in the history
Co-authored-by: Svein Erik <sundstei@gmail.com>
  • Loading branch information
oskogstad and sundstei authored Feb 27, 2024
1 parent ca80d36 commit 69b15e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docker compose up
The APIs SwaggerUI should now be available at [localhost:7124/swagger](https://localhost:7214/swagger/index.html)

### Running the WebApi in an IDE
If you need do debug the WebApi project in an IDE, you can alternatively run docker compose without the WebAPI.
If you need to debug the WebApi project in an IDE, you can alternatively run docker compose without the WebAPI.
First create a dotnet user secret for the DB connection string.

```powerhell
Expand Down Expand Up @@ -59,21 +59,25 @@ dotnet ef migrations add TestMigration
```
## Testing

Besides ordinary unit- and integration tests, there are test suites for both functional end-to-end testing implemented with [K6](https://k6.io/).
Besides ordinary unit and integration tests, there are test suites for both functional and non-functional end-to-end tests implemented with [K6](https://k6.io/).

See `tests/k6/README.md` for more information.

## Development in local and test environments
To generate test tokens see https://github.com/Altinn/AltinnTestTools. There is a request in the Postman collection for this.
To generate test tokens see, https://github.com/Altinn/AltinnTestTools. There is a request in the Postman collection for this.

### Local development settings
We are able to toggle some external resources in local development. This is done through the `appsettings.Development.json` file. The following settings are available:
```json
"LocalDevelopment": {
"UseLocalDevelopmentUser": true,
"UseLocalDevelopmentResourceRegister": true,
"UseLocalDevelopmentCloudEventBus": true,
"DisableAuth": true
"UseLocalDevelopmentUser": true,
"UseLocalDevelopmentResourceRegister": true,
"UseLocalDevelopmentOrganizationRegister": true,
"UseLocalDevelopmentNameRegister": true,
"UseLocalDevelopmentAltinnAuthorization": true,
"UseLocalDevelopmentCloudEventBus": true,
"DisableShortCircuitOutboxDispatcher": true,
"DisableAuth": true
}
```
Toggling these flags will enable/disable the external resources. The `DisableAuth` flag, for example, will disable authentication in the WebAPI project. This is useful when debugging the WebAPI project in an IDE. These settings will only be respected in the `Development` environment.
16 changes: 8 additions & 8 deletions src/Digdir.Tool.Dialogporten.SlackNotifier/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Slack notifier
This function app is designed to convert Azure log alert v2 to a slack message formatted as an ascii table.
This function app is designed to convert Azure log alert v2 to a Slack message formatted as an ASCII table.

When a Azure log alert triggers it notifies every consumer of the configured Azure action group. One of the consumers is this Azure function app which receives a HTTP Post request with the [log alert v2 format](https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-common-schema#sample-log-alert-when-the-monitoringservice--log-alerts-v2). See [AzureAlertDto.cs](./Features/AzureAlertToSlackForwarder/AzureAlertDto.cs) for the format this function app expects.

The log alert v2 format does not include the actual query data which triggered the alert. Therefore the function app must fetch it by calling application insight. The data is then transformed to an ascii table and pushed to the configured slack webhook url through the field `exceptionReport`. It will also include a link to the application insight log with the following predefined query in the field named `link`:
The log alert v2 format does not include the actual query data which triggered the alert. Therefore the function app must fetch it by calling application insight. The data is then transformed to an ASCII table and pushed to the configured Slack webhook URL through the field `exceptionReport`. It will also include a link to the application insight log with the following predefined query in the field named `link`:
```KQL
exceptions
| order by timestamp desc
```

The configured slack webhook will receive the following request:
The configured Slack webhook will receive the following request:
```HTTP
HTTP POST [Slack_Webhook_Url]
{
Expand All @@ -20,21 +20,21 @@ HTTP POST [Slack_Webhook_Url]

## Local development
1. [Login to azure](https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication/?tabs=command-line#exploring-the-sequence-of-defaultazurecredential-authentication-methods)
2. Configure the slack webhook url
2. Configure the Slack webhook URL
```powerhell
dotnet user-secrets set -p .\src\Digdir.Tool.Dialogporten.SlackNotifier\ "Slack:WebhookUrl" "SLACK_WEBHOOK_URL_HERE"
```
3. Start the function app
4. Send a log alert v2 format to the app
The configured url doesn't have to be an actual slack workflow webhook url. It could point to an online webhook tester like https://webhook.site or a homemade webhook tester on your local machine.
The configured URL doesn't have to be an actual Slack workflow webhook URL. It could point to an online webhook tester like https://webhook.site or a homemade webhook tester on your local machine.
### Get a valid log alert v2 request
This function app uses the links in the incoming alerts request to fetch data. Therefore the requests are app instance and time specific. The provided example request is most likely to be invalid by the time this article is read. Do the following to get a valid request:
1. Go to https://webhook.site and copy your unique url
2. Add the url as a webhook action of the azure action group
1. Go to https://webhook.site and copy your unique URL
2. Add the URL as a webhook action of the azure action group
3. Trigger the alert
4. Copy the request from https://webhook.site into postman. It may take several minutes for the alert to produce a request to the webhook.
4. Copy the request from https://webhook.site into Postman. It may take several minutes for the alert to produce a request to the webhook.
5. Delete the webhook action from the azure action group
Example log alert v2 request:
Expand Down

0 comments on commit 69b15e8

Please sign in to comment.