Skip to content

Commit

Permalink
fixed bug in gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
vallard committed Aug 2, 2022
1 parent 2063618 commit 873953e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
Binary file modified app-api/app/__pycache__/main.cpython-39.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions app-api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from prometheus_fastapi_instrumentator import Instrumentator
from prometheus_client import Gauge

TOTAL_USERS = Gauge("total_users", "Total users")

# END PROMETHEUS (part 5)


Expand All @@ -49,7 +51,7 @@
app.include_router(user.router)
app.include_router(auth.router)

# PREMETHEUS (part 5)
# PROMETHEUS (part 5)
@app.on_event("startup")
def init_instrumentator():
"""Setup prometheus instrumentation for the API"""
Expand All @@ -61,7 +63,7 @@ def init_instrumentator():
def periodic():
count = engine.execute("select count(id) from user").scalar()
logger.info(f"Number of users: {count}")
Gauge("total_users", "Total Users").set(int(count))
TOTAL_USERS.set(int(count))


# END PROMETHEUS (part 5)
Expand Down
Binary file added images/mo/m08-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mo/m08-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion m04/custom/k8s-configMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ data:
{
"evaluator": {
"params": [
0.9
0.85
],
"type": "gt"
},
Expand Down
2 changes: 1 addition & 1 deletion m04/slack-notifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ data:
type: slack
uid: QwYpzLaGz
secure_settings:
url: <put in your webhook>
url: <put in your slack webhook here>
20 changes: 20 additions & 0 deletions m08-app-logging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,23 @@ There are some changes we made with this next version:
* Before the default settings scraped the logs from the individual nodes. It still does this but now the app forwards to fluent on its own. Fluent in turn flows to OpenSearch.

![](../images/mo/m08-01.png)

## Curate the Logs

Opensearch allows us to delete after X number of days

![os policy](../images/mo/m08-02.png)

We create the policy first. Then apply it to the fluentd group

![apply os policy](../images/mo/m08-03.png)


## Make a Dashboard

In Discover we can save our search with

```
logger_name:myapp
```
We can then do `Save` to save this search. We can then add this to a dashboard, or use it to quickly look back to.

0 comments on commit 873953e

Please sign in to comment.