๐Ÿ“—
smiley book
  • Smiley Books
  • AI
    • Readme
    • openai-whisper
      • ์ƒ˜ํ”Œ ์‹คํ–‰ํ•ด๋ณด๊ธฐ
      • GPU ์„œ๋ฒ„ ์ค€๋น„ํ•˜๊ธฐ
      • API๋กœ whisper๋ฅผ ์™ธ๋ถ€์— ์˜คํ”ˆํ•˜๊ธฐ
      • ํ”„๋กฌํ”„ํŠธ ์ง€์›
      • ์‹ค์‹œ๊ฐ„ message chat
      • ํ™”๋ฉด ์ด์˜๊ฒŒ ๋งŒ๋“ค๊ธฐ์™€ ๋กœ๊ทธ์ธ
      • ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ
      • ์‹ค์‹œ๊ฐ„ voice chat
      • fine tunning(๋ฏธ์„ธ ์กฐ์ •) ์œผ๋กœ ์„ฑ๋Šฅ ์˜ฌ๋ฆฌ๊ธฐ
      • app์—์„œ api๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ…์ŠคํŠธ๋กœ ๋ฐ”๊ฟ”๋ณด๊ธฐ
    • ollama - llm์„ ์‰ฝ๊ฒŒ ๋‚ด์ปด์—์„œ ์‹คํ–‰
      • ollama webui
      • ollama docker
    • stable diffusion
      • SDXL - text to image
      • SD-webui
    • ChatGPT
      • ๋‹ต๋ณ€์ด ๋Š๊ธธ๋•Œ
      • ์—ญํ• ์„ ์ •ํ•˜์ž
      • ๊ตฌ์ฒด์ ์ธ ์งˆ๋ฌธ
      • ๊ฒฐ๊ณผํ˜•ํƒœ๋ฅผ ์ง€์ •
      • ํ”„๋กฌํ”„ํŠธ๋ฅผ ์—ฌ๋Ÿฌ์ค„๋กœ ์‚ฌ์šฉํ•˜์ž.
      • ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ ๊ธ€ ๋ฒˆ์—ญ๋ณธ
    • Prompt Engineering
    • Auto-GPT
    • Gemini
      • google ai studio
      • gemini-api
      • embedding guide
    • Huggingface
      • huggingface ์‚ฌ์šฉ๋ฒ•
      • huggingface nlp ๊ณต๋ถ€์ค‘
    • kaggle
      • download dataset
    • langchain
      • langchain์„ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ •๋ฆฌ
      • basic
      • slackbot
      • rag
      • document-loader
      • website-loader
      • confluence
      • memory
      • function-call
      • langsmith
      • agent-toolkit
  • Ansible
    • templates vs files and jinja2
    • dynamic inventory
    • limit ์˜ต์…˜ ๊ฐ•์ œํ•˜๊ธฐ
    • limit ์‚ฌ์šฉํ›„ gather_fact ๋ฌธ์ œ
  • AWS
    • AWS CLI
    • EKS
      • cluster manage
      • ALB Controller
      • external-dns
      • fargate
    • ECR
    • S3
    • Certificate Manager
  • Azure
    • Azure AD OAuth Client Flow
  • Container
    • Registry
    • ๋นŒ๋“œ์‹œ์— env๊ฐ’ ์„ค์ •ํ•˜๊ธฐ
  • DB
    • PXC
      • Operator
      • PMM
      • ์‚ญ์ œ
      • GTID
      • Cross Site Replication
    • Mssql
    • Mysql
  • dotnet
    • Thread Pool
    • Connection Pool
    • Thread Pool2
  • Devops
    • Recommendation
  • GIT
    • Basic
    • Submodule
  • GitHub
    • Repository
    • GitHub Action
    • GitHub PR
    • Self Hosted Runner
    • GitHub Webhook
  • GitLab
    • CI/CD
    • CI/CD Advance
    • Ssl renew
    • CI/CD Pass env to other job
  • Go Lang
    • ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•
    • multi os binary build
    • kubectl๊ฐ™์€ cli๋งŒ๋“ค๊ธฐ
    • azure ad cli
    • embed static file
    • go study
      • pointer
      • module and package
      • string
      • struct
      • goroutine
  • Kubernetes
    • Kubernetes๋Š” ๋ฌด์—‡์ธ๊ฐ€
    • Tools
    • Install with kubespray
    • Kubernetes hardening guidance
    • 11 ways not to get hacked
    • ArgoCD
      • Install
      • CLI
      • Repository
      • Apps
      • AWS ALB ์‚ฌ์šฉ
      • Notification slack
      • Backup / DR
      • Ingress
      • 2021-11-16 Github error
      • Server Config
      • auth0 ์ธ์ฆ ์ถ”๊ฐ€(oauth,OIDC)
    • Extension
      • Longhorn pvc
      • External dns
      • Ingress nginx
      • Cert Manager
      • Kube prometheus
    • Helm
      • Subchart
      • Tip
    • Loki
    • Persistent Volume
    • TIP
      • Job
      • Pod
      • Log
  • KAFKA
    • raft
  • KVM
    • kvm cpu model
  • Linux
    • DNS Bind9
      • Cert-Manager
      • Certbot
      • Dynamic Update
      • Log
    • Export and variable
    • Grep ์‚ฌ์šฉ๋ฒ•
  • Modeling
    • C4 model introduce
    • Mermaid
    • reference
  • Monitoring
    • Readme
    • 0. What is Monitoring
    • 1. install prometheus and grafana
    • 2. grafana provisioning
    • 3. grafana dashboard
    • 4. grafana portable dashboard
    • 5. prometheus ui
    • 6. prometheus oauth2
    • Prometheus
      • Metric type
      • basic
      • rate vs irate
      • k8s-prometheus
    • Grafana
      • Expolorer
    • Node Exporter
      • advance
      • textfile collector
  • Motivation
    • 3 Simple Rule
  • OPENNEBULA
    • Install(ansible)
    • Install
    • Tip
    • Windows vm
  • Reading
    • comfort zone
    • ๋ฐฐ๋ ค
    • elon musk 6 rule for insane productivity
    • Feynman Technique
    • how to interview - elon musk
    • ๊ฒฝ์ฒญ
    • Readme
  • Redis
    • Install
    • Master-slave Architecture
    • Sentinel
    • Redis Cluster
    • Client programming c#
  • SEO
    • Readme
  • Security
    • criminalip.io
      • criminalip.io
  • Stock
    • robinhood-python
  • Terraform
    • moved block
    • output
  • vault
    • Readme
  • VS Code
    • dev container
    • dev container on remote server
  • Old fashione trend
    • curity
    • MAAS
      • Install maas
      • Manage maas
      • Tip
Powered by GitBook
On this page
  • install Loki stack
  • deploy
  • setting
  • ๋ฐ์ดํ„ฐ ํ™•์ธํ•˜์ž
  • Log Stream Selector
  • filter expression
  • sample
  • Pattern Parser

Was this helpful?

  1. Kubernetes

Loki

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์— grafana๊ฐ€ ๋ฒŒ์จ ์„ค์น˜๋˜์ž‡๋‹ค. loki๋ฅผ ์ฟ ๋ฒ ์— ์„ค์น˜ํ•ด๋ณด์ž.

install Loki stack

helm subchart๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค. argocd๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•จ.

apiVersion: v2
name: core-loki-stack
type: application
version: 1.0.0
appVersion: '1.0.0'
dependencies:
  - name: loki-stack
    version: 2.4.1
    repository: https://grafana.github.io/helm-charts

deploy

argocd๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐํฌ๋ฅผ ํ•˜์˜€๋‹ค.

setting

grafana์— ์ ‘์†ํ›„ data source๋ฅผ ์ถ”๊ฐ€ํ•˜์˜€๋‹ค.

http://core-loki-stack:3100 ์‚ฌ์šฉ. ์„œ๋น„์Šค๋ช…์ด๋‹ค.

๋ฐ์ดํ„ฐ ํ™•์ธํ•˜์ž

์‚ฌ์ด๋“œ ๋ฉ”๋‰ด์—์„œ explorer๋ฅผ ์„ ํƒ

์ƒ๋‹จ ๋ฉ”๋‰ด์—์„œ loki๋ฅผ ์„ ํƒํ•œ๋‹ค.

๋นˆ ํ™”๋ฉด์ด ๋‚˜์˜ฌ๊ฒƒ์ด๋‹ค. ์ด๊ฑธ ์‚ฌ์šฉํ•˜๋ ค๋ฉด LogQL์„ ์•Œ์•„์•ผ ํ•œ๋‹ค.

๋กœ๊ทธ ์ฟผ๋ฆฌ๋Š” log stream selector์™€ filter expression ์ด๋ ‡๊ฒŒ ๋‘ ๋ถ€๋ถ„์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค.

Log Stream Selector

์ฟผ๋ฆฌ ํ‘œํ˜„์‹์˜ label ๋ถ€๋ถ„์„ ์ค‘๊ด„ํ˜ธ {}๋กœ ๋ฌถ์€ ๋‹ค์Œ key value ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ label์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์ˆ˜์˜ label ํ‘œํ˜„์‹๋“ค์€ ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„ํ•ฉ๋‹ˆ๋‹ค.

{namespace="kube-system",pod="core-dns-66bff467f8-2jz7d"}

์ด๋Ÿฐ์‹์ด๋‹ค. ์‰ฝ๊ฒŒ ํ•˜๊ธฐ์œ„ํ•ด์„œ ๋กœ๊ทธ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ๋ˆ„๋ฅธ๋‹ค. ํ˜„์žฌ ์„ ํƒ์ด ๊ฐ€๋Šฅํ•œ selector๋“ค์ด ๋ณด์ธ๋‹ค. ์—ฌ๊ธฐ์„œ namespace๋ฅผ ํด๋ฆญํ•ด๋ณด์ž.

์ด์ œ ์›ํ•˜๋Š” ๋„ค์ž„ ์ŠคํŽ˜์ด์Šค๋ฅผ ๋ˆ„๋ฅผ์ˆ˜ ์žˆ๋‹ค.

์ด์ œ ๊ฐ์ฒด๋“ค์ด ์„ ํƒ๋˜์–ด์„œ ๋‚ด์šฉ์ด ๋ณด์ธ๋‹ค.

  • label ๋งค์นญ ์—ฐ์‚ฐ์ž

    • = ์ •ํ™•ํžˆ ๋™์ผํ•จ.

    • != ๋™์ผํ•˜์ง€ ์•Š์Œ.

    • =~ ์ •๊ทœํ‘œํ˜„์‹ ๋งค์นญ.

    • !~ ์ •๊ทœํ‘œํ˜„์‹์— ๋งค์นญ๋˜์ง€ ์•Š์Œ.

  • sample

    • {name=~"kubernetes.+"}

    • {name!~"kubernetes.+"}

filter expression

๋‚˜์˜จ ๊ฒฐ๊ณผ๋ฅผ ๋‹ค์‹œ ํ•„ํ„ฐํ• ์ˆ˜ ์žˆ๋‹ค.

  • Keep log lines that have the substring โ€œerrorโ€:

|= "error"
  • A complete query using this example:

{job="mysql"} |= "error"
  • Discard log lines that have the substring โ€œkafka.server:type=ReplicaManagerโ€:

!= "kafka.server:type=ReplicaManager"
  • A complete query using this example:

{instance=~"kafka-[23]",name="kafka"} != "kafka.server:type=ReplicaManager"
  • Keep log lines that contain a substring that starts with tsdb-ops and ends with io:2003. A complete query with a regular expression:

{name="kafka"} |~ "tsdb-ops.\*io:2003"
  • Keep log lines that contain a substring that starts with error=, and is followed by 1 or more word characters. A complete query with a regular expression:

{name="cassandra"} |~ `error=\w+`

์ด๋Ÿฐ์‹์œผ๋กœ ํ•„ํ„ฐํ• ์ˆ˜ ์žˆ๋‹ค.

ํ•„ํ„ฐ ์—ฐ์‚ฐ์ž๋“ค์€ ์—ฐ๊ฒฐ๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ํ‘œํ˜„์‹์„ ์ˆœ์ฐจ์ ์œผ๋กœ ํ•„ํ„ฐ๋งํ•ฉ๋‹ˆ๋‹ค. ๊ฒฐ๊ณผ๊ฐ’์œผ๋กœ ์ถœ๋ ฅ๋˜๋Š” ๋กœ๊ทธ ๋ผ์ธ๋“ค์€ ๋ชจ๋“  ํ•„ํ„ฐ๋ฅผ ์ถฉ์กฑํ•ฉ๋‹ˆ๋‹ค.

{job="mysql"} |= "error" != "timeout"

- |= ๋ฌธ์ž์—ด์„ ํฌํ•จํ•˜๋Š” ๋ผ์ธ.
- != ๋ฌธ์ž์—ด์„ ํฌํ•จํ•˜์ง€ ์•Š๋Š” ๋ผ์ธ.
- |~ ์ •๊ทœ ํ‘œํ˜„์‹์— ๋งค์นญ๋˜๋Š” ๋ผ์ธ.
- !~ ์ •๊ทœ ํ‘œํ˜„์‹์— ๋งค์นญ๋˜์ง€ ์•Š๋Š” ๋ผ์ธ.

๋งค์นญ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋Œ€์†Œ ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜๋ฉฐ (?i)๋ฅผ ์ •๊ทœ ํ‘œํ˜„์‹ ์•ž์— ์ ‘๋‘์‚ฌ๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๋Œ€์†Œ ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š๋„๋ก ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

sample

{namespace="kube-system"} |= "[ERROR]"

Pattern Parser

์ƒˆ๋กœ์šด ๋ฒ„์ „๋ถ€ํ„ฐ ์ ์šฉ๋จ.

{namespace=~"ingress-nginx|ingress-nginx-internal"}  | pattern `<remote_ip> - - <_> "<method> <_> <_>" <status> <_> <_> "<_>" <_>`

์ด๋Ÿฌ๋ฉด ์งค๋ผ์„œ ๋ณด์—ฌ์ค€๋‹ค. ์—ฌ๊ธฐ์„œ ํ•„ํ„ฐ๋ฅผ ๋‹ค์‹œ ๊ฑธ๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•˜์ง€?

{namespace=~"ingress-nginx|ingress-nginx-internal"}  | pattern `<remote_ip> - - <_> "<method> <_> <_>" <status> <_> <_> "<_>" <_>`  | status="400"

{namespace=~"ingress-nginx|ingress-nginx-internal"}  | pattern `<remote_ip> - - <_> "<method> <_> <_>" <status> <_> <_> "<_>" <_>`  | status=~"[4-5].*"
PreviousTipNextPersistent Volume

Last updated 1 year ago

Was this helpful?

๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์—์„œ ์ฐธ๊ณ ํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค.

https://grafana.com/docs/loki/latest/logql/
https://grafana.com/docs/loki/latest/logql/