datadog-flask-redis-sandbox
所属分类:Redis
开发工具:HCL
文件大小:0KB
下载次数:0
上传日期:2024-02-27 08:13:52
上 传 者:
sh-1993
说明: 一个虚拟的Web应用程序,用户单击按钮,事情就会发生。使用Datadog检测度量、RUM、日志和跟踪。
(A dummy webapp, where users click a button and things happen. Instrumented with Datadog for Metrics, RUM, Logs and Traces.)
文件列表:
datadog/
flask/
redis/
terraform/
.env
app.png
compose.yml
terraform.sh
## Overview
A dummy webapp, where users click a button and things happen. Instrumented with Datadog for Metrics, RUM, Logs and Traces.
![app overview](https://github.com/app.png)
**Flask** handles cookie-based authentication, web page template rendering and some back-end plumbery.
Clicking the big button increments a counter for that user, stored in **Redis**. But it may fail, and run take 100s of milliseconds to run.
The webapp comes with a basic collection of Datadog Monitors and Dashboards, deployable through a wrapped and dockerized [Terraform CLI](https://github.comhttps://developer.hashicorp.com/terraform/cli/commands).
## How To
### Setup
1. install [Docker Desktop](https://github.comhttps://www.docker.com/products/docker-desktop/)
2. Create a [Datadog Org](https://github.comhttps://app.datadoghq.com/signup), and update `DD_SITE` in the `.env` file (see [documentation](https://github.comhttps://docs.datadoghq.com/getting_started/site/#access-the-datadog-site) for reference)
3. Get an [API key](https://github.comhttps://app.datadoghq.com/organization-settings/api-keys), an [APP key](https://github.comhttps://app.datadoghq.com/organization-settings/application-keys) as well as a [Client Token](https://github.comhttps://app.datadoghq.com/organization-settings/client-tokens), and update `DD_API_KEY`, `DD_APP_KEY` and `DD_CLIENT_TOKEN` accordingly in the `.env` file.
4. Create a [Datadog RUM Application](https://github.comhttps://app.datadoghq.com/rum/application/create) for Javascript, and update `DD_APPLICATION_ID` in the `.env` file.
5. Update the `NOTIF_EMAIL` in the `.env` file with an email where to send datadog notifications (you can use the email you used for your Datadog Account).
### Run
Run `docker compose up` from a terminal at the root of the `redis-sandbox` folder:
```bash
$ docker compose up
[+] Running 3/3
Container redis Created 10.0s
Container datadog Created 10.0s
Container flask Created 10.0s
```
Ctrl-C would kill the app.
### Play
From a web browser:
* Connect to `http://localhost:8000`. You'll be logged in as a random user `abcd1234@sandbox.com`.
* Alternatively, log in as any user injecting their user_id in the URL (yay... security): `http://localhost:8000/?user_id=john.doe`.
Your cookie expires when you close your browser.
### Terraform
Terraform runs within a docker container, with working directory properly wired to the terraform configuration (see [--chdir option](https://github.comhttps://developer.hashicorp.com/terraform/cli/commands#switching-working-directory-with-chdir) )
``` bash
$ ./terraform.sh init
Initializing the backend...
[...]
Terraform has been successfully initialized!
```
``` bash
$ ./terraform.sh apply
[...]
Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
```
``` bash
$ ./terraform.sh output monitor_tags
[
"env:sandbox",
"owner:terraform"
]
```
``` bash
$ ./terraform.sh destroy
[...]
Destroy complete! Resources: 3 destroyed.
```
### Observe
* [Service Catalog](https://github.comhttps://app.datadoghq.com/metric/summary?tags=env%3Asandbox)
* [Metrics](https://github.comhttps://app.datadoghq.com/metric/summary)
* [Logs](https://github.comhttps://app.datadoghq.com/logs?query=env%3Asandbox)
* [Trace](https://github.comhttps://app.datadoghq.com/apm/traces?query=%40_top_level%3A1%20env%3Asandbox)
* [RUM Events](https://github.comhttps://app.datadoghq.com/rum/explorer?query=%40type%3Asession)
... [Dashboards](https://github.comhttps://app.datadoghq.com/dashboard/lists), [Monitors](https://github.comhttps://app.datadoghq.com/monitors#recommended?q=integration:Redis&p=1)
近期下载者:
相关文件:
收藏者: