From 11d8bc8a2c963c469a9067a472fbc02e9a1fc112 Mon Sep 17 00:00:00 2001 From: vallard Date: Sun, 31 Jul 2022 17:23:33 -0700 Subject: [PATCH] make the logging work --- 02/terragrunt/modules/vpc/main.tf | 2 + README.md | 13 +- app-api/app-api.yaml | 1 + app-api/app/__pycache__/main.cpython-39.pyc | Bin 1945 -> 1942 bytes app-api/app/main.py | 12 +- .../routers/__pycache__/auth.cpython-39.pyc | Bin 2463 -> 2495 bytes app-api/app/routers/auth.py | 3 +- m03/README.md | 22 ++- m06/README.md | 6 +- m07-fek/README.md | 4 +- m07-fek/kibana-proxy.yaml | 2 +- m07-fek/values.yaml | 2 +- m08-app-logging/README.md | 11 ++ m08-app-logging/app-api.yaml | 178 ++++++++++++++++++ m08-app-logging/values2.yaml | 47 +++++ 15 files changed, 284 insertions(+), 19 deletions(-) create mode 100644 m08-app-logging/app-api.yaml create mode 100644 m08-app-logging/values2.yaml diff --git a/02/terragrunt/modules/vpc/main.tf b/02/terragrunt/modules/vpc/main.tf index 2b342e8..363e8eb 100644 --- a/02/terragrunt/modules/vpc/main.tf +++ b/02/terragrunt/modules/vpc/main.tf @@ -31,3 +31,5 @@ module "vpc_example_simple-vpc" { } } + + diff --git a/README.md b/README.md index e44b171..aadd009 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,12 @@ In this segment we'll go over some Kubernetes primitives. We move fast, show wh ### M05 - Integrate Grafana/Prometheus in our Application -* [README](m05/README.md) +* [Intro](m05/README.md) +* [FastAPI and Prometheus](m05/README.md#fastapi-and-prometheus) +* [Prometheus client](m05/README.md#prometheus-client) +* [Scraping](m05/README.md#scraping) +* [Grafana Integration](m05/README.md#grafana-integration) +* [Persistence](m05/README.md#adding-persistence) ### M06 - CloudWatch Alarms @@ -95,7 +100,11 @@ In this segment we'll go over some Kubernetes primitives. We move fast, show wh ### M07 - FEK Stack -* [README](m07-fek/README.md) +* [Intro](m07-fek/README.md#components) +* [Configuration](m07-fek/README.md#installation-and-configuration) +* [Fluentd](m07-fek/README.md#fluentd) +* [Kibana](m07-fek/README.md#viewing-logs) + ### M08 - Application Logging diff --git a/app-api/app-api.yaml b/app-api/app-api.yaml index eb07433..149788f 100644 --- a/app-api/app-api.yaml +++ b/app-api/app-api.yaml @@ -92,6 +92,7 @@ spec: name: k8s-sample-db-secrets - configMapRef: name: k8s-sample-db-cm + --- apiVersion: apps/v1 kind: Deployment diff --git a/app-api/app/__pycache__/main.cpython-39.pyc b/app-api/app/__pycache__/main.cpython-39.pyc index e13d7c316d5dc5ab988c3daff44d78fe6e041822..42d5d89d1f3c43ae72752f81bb40cd126a0e4185 100644 GIT binary patch delta 646 zcmYjOO>fgc5Z!TXCynEL(8NxQOiiH)p;gL(4+*#+R0^Wv0$eOaNZ74$<;2n27APv> z5N@c4Xe9(fNDe2?An`M}aLXS+{0qjGg79i*-@G@w`#k%x^1hzuDvlZwV0Khp~X1>aS7GFfV08OBb#Y#gO;f7 zLN?1M3T`)(v#fHonbu~w`X8?S!{=ya4zx;ZZ^;y#^H`ZNOsA*t#MKjt)@dWvx+rfg zWopn$wxN|VCLYnGX2!HBJS3ep@fDt4(?b@;TC*&>WSgQldurW3-!cl%Nwuv}J2|QhN{&2aManp&f^ehu3XKi-M@{_p)@NJxUY% zajJC+;+bqz7iwyp@rCS-4g+2iujJkO4RjK!>C5HHPzAn@NL*Adi9hlV+!2Pd2dBjo zWxHmfa35zVVIWfHg7~0(Go97`c--~9K^NC$V|Y>QtCw3E);YB?4~8sy!Q!y@-1o3i zyo5Y&q`|--eyO*#^j2O@gC#cdt@Z)J0@^7ohg5=e)R8MmDyTAMiYmtW&HPFMigE$| E0%WDm?E!K<=?4qkbzVEB*u6|p3SF%U8Z82KcKK*?BVqv>*yy(7i zL~hRf>X?b@a19w6liI%HJHQs->d()iH3wis!^HJn;l}6DO2A(i>v0qF326bt!Uym- zM0IadS}Kx!@wZF`H7sWZmomm7rjAa=bPyi0&RO{ecBI0cRtJ{$R7A6*;p8v~#s`6~ zjE=@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auth.py index f37cdc7..de2b6d7 100644 --- a/app-api/app/routers/auth.py +++ b/app-api/app/routers/auth.py @@ -10,6 +10,7 @@ create_access_token, ) from app.lib.slack import SlackClient +from app.lib.app_logging import setup_logging from sqlalchemy.orm import Session import logging from typing import Any @@ -27,7 +28,7 @@ # Fluent (part 8) -logger = logging.getLogger("api.auth") +logger = setup_logging() # END Fluent (part 8) diff --git a/m03/README.md b/m03/README.md index e645403..731340f 100644 --- a/m03/README.md +++ b/m03/README.md @@ -212,4 +212,24 @@ We can also see graphs of these queries by checking out the graph button ![graph of free](../images/mo/prom02.png) -This graph shows that our nodes are around 50% capacity in memory. \ No newline at end of file +This graph shows that our nodes are around 50% capacity in memory. + +## Kube-Proxy + +As part of the set up the `kube-proxy` in EKS doesn't work. We have to patch this: + +``` +kubectl edit cm kube-proxy-config -n kube-system +## Change from + metricsBindAddress: 127.0.0.1:10249 ### <--- Too secure +## Change to + metricsBindAddress: 0.0.0.0:10249 +``` + +Then restart the `kube-proxies`: + +``` +kubectl rollout restart ds kube-proxy -n kube-system +``` + +(credit: [alternaivan](https://github.com/prometheus-community/helm-charts/issues/977#issuecomment-888161858) diff --git a/m06/README.md b/m06/README.md index 5b2f3d5..03e1e6b 100644 --- a/m06/README.md +++ b/m06/README.md @@ -11,14 +11,14 @@ To do this we follow the [instructions](https://docs.aws.amazon.com/eks/latest/u ``` aws eks update-cluster-config \ --region us-west-2 \ - --name eks-stage \ + --name eks-stage-mon \ --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}' ``` ## Analyzing metrics in Cloud Watch -We visit (CloudWatch)[https://console.aws.amazon.com/cloudwatch/home#logs:prefix=/aws/eks] and search for the prefix `/aws/eks`. This should show all our clusters. +We visit [CloudWatch](https://console.aws.amazon.com/cloudwatch/home#logs:prefix=/aws/eks) and search for the prefix `/aws/eks`. This should show all our clusters. There are several different logs we can see: @@ -51,5 +51,5 @@ In future classes we may add how to do this explicitly to this section. aws eks update-cluster-config \ --region us-west-2 \ - --name eks-stage \ + --name eks-stage-mon \ --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":false}]}' diff --git a/m07-fek/README.md b/m07-fek/README.md index be748d2..a8931cb 100644 --- a/m07-fek/README.md +++ b/m07-fek/README.md @@ -1,4 +1,4 @@ -# The FEK Stack +# The EFK Stack Logging information from your applications to search, verify, and index on is a great idea and gives added visibility. In a production environment developers are constantly looking at logs to analyze user behavior, what went wrong, and find ways to improve the system. @@ -33,7 +33,7 @@ This lets us login with our standard username/password and now we can visit: ![open search dashboard](../images/mo/fek01.png) -There's not much to see in here right now because there is +There's not much to see in here right now because there isn't data being exported to it from fluent! diff --git a/m07-fek/kibana-proxy.yaml b/m07-fek/kibana-proxy.yaml index 24f83bf..5ec35ff 100644 --- a/m07-fek/kibana-proxy.yaml +++ b/m07-fek/kibana-proxy.yaml @@ -8,7 +8,7 @@ metadata: namespace: monitoring spec: type: ExternalName - externalName: vpc-opensearch-stage-woesdamvqbli5siagd7guw7ubi.us-west-2.es.amazonaws.com + externalName: vpc-opensearch-stage-mon-fhdhhs2ktec5zddpepkno2ereu.us-west-2.es.amazonaws.com --- apiVersion: networking.k8s.io/v1 kind: Ingress diff --git a/m07-fek/values.yaml b/m07-fek/values.yaml index 8211469..1f4bb61 100644 --- a/m07-fek/values.yaml +++ b/m07-fek/values.yaml @@ -6,7 +6,7 @@ fileConfigs: