diff --git a/.gitignore b/.gitignore index c9a0a77c..9ee8a033 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.tgz -Chart.lock \ No newline at end of file +Chart.lock +.DS_Store diff --git a/charts/loki/Chart.yaml b/charts/loki/Chart.yaml new file mode 100644 index 00000000..9ace251b --- /dev/null +++ b/charts/loki/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: loki +description: A Helm chart for loki +type: application +version: 0.1.0 +appVersion: 1.0.0 +dependencies: + - name: loki-distributed + version: 0.76.1 + repository: https://grafana.github.io/helm-charts + alias: logging + tags: + - logging + condition: distributed.enabled + - name: promtail + version: 6.16.4 + repository: https://grafana.github.io/helm-charts + alias: promtail + tags: + - logging + - name: loki + version: 6.7.3 + repository: https://grafana.github.io/helm-charts + alias: logging + tags: + - logging + condition: standalone.enabled \ No newline at end of file diff --git a/charts/loki/distributed/values.yaml b/charts/loki/distributed/values.yaml new file mode 100644 index 00000000..a091173f --- /dev/null +++ b/charts/loki/distributed/values.yaml @@ -0,0 +1,501 @@ +logging: + gateway: + # image: + # registry: + # repository: + # tag: 1.20.2-alpine + enabled: true + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 2 + resources: + requests: + memory: 500Mi + cpu: 200m + limits: + memory: 500Mi + cpu: 200m + nginxConfig: + file: | + worker_processes 5; ## Default: 1 + error_log /dev/stderr; + pid /tmp/nginx.pid; + worker_rlimit_nofile 8192; + + events { + worker_connections 4096; ## Default: 1024 + } + + http { + client_body_temp_path /tmp/client_temp; + proxy_temp_path /tmp/proxy_temp_path; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; + + client_max_body_size 5M; + + proxy_http_version 1.1; + + default_type application/octet-stream; + log_format {{ .Values.gateway.nginxConfig.logFormat }} + + {{- if .Values.gateway.verboseLogging }} + access_log /dev/stderr main; + {{- else }} + + map $status $loggable { + ~^[23] 0; + default 1; + } + access_log /dev/stderr main if=$loggable; + {{- end }} + + sendfile on; + tcp_nopush on; + {{- if .Values.gateway.nginxConfig.resolver }} + resolver {{ .Values.gateway.nginxConfig.resolver }}; + {{- else }} + resolver {{ .Values.global.dnsService }}.{{ .Values.global.dnsNamespace }}.svc.{{ .Values.global.clusterDomain }}; + {{- end }} + + {{- with .Values.gateway.nginxConfig.httpSnippet }} + {{ . | nindent 2 }} + {{- end }} + + server { + listen 8080; + + {{- if .Values.gateway.basicAuth.enabled }} + auth_basic "Loki"; + auth_basic_user_file /etc/nginx/secrets/.htpasswd; + {{- end }} + + location = / { + return 200 'OK'; + auth_basic off; + access_log off; + } + + location = /api/prom/push { + set $api_prom_push_backend http://{{ include "loki.distributorFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}; + proxy_pass $api_prom_push_backend:3100$request_uri; + proxy_http_version 1.1; + } + + location = /api/prom/tail { + set $api_prom_tail_backend http://{{ include "loki.querierFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}; + proxy_pass $api_prom_tail_backend:3100$request_uri; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_http_version 1.1; + } + + # Ruler + location ~ /prometheus/api/v1/alerts.* { + proxy_pass http://{{ include "loki.rulerFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:3100$request_uri; + } + location ~ /prometheus/api/v1/rules.* { + proxy_pass http://{{ include "loki.rulerFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:3100$request_uri; + } + location ~ /api/prom/rules.* { + proxy_pass http://{{ include "loki.rulerFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:3100$request_uri; + } + location ~ /api/prom/alerts.* { + proxy_pass http://{{ include "loki.rulerFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:3100$request_uri; + } + + location ~ /api/prom/.* { + set $api_prom_backend http://{{ include "loki.queryFrontendFullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}; + proxy_pass $api_prom_backend:3100$request_uri; + proxy_http_version 1.1; + } + + location = /loki/api/v1/push { + set $loki_api_v1_push_backend http://{{ include "loki.distributorFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}; + proxy_pass $loki_api_v1_push_backend:3100$request_uri; + proxy_http_version 1.1; + } + + location = /loki/api/v1/tail { + set $loki_api_v1_tail_backend http://{{ include "loki.querierFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}; + proxy_pass $loki_api_v1_tail_backend:3100$request_uri; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_http_version 1.1; + } + + location ~ /loki/api/.* { + set $loki_api_backend http://{{ include "loki.queryFrontendFullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}; + proxy_pass $loki_api_backend:3100$request_uri; + proxy_http_version 1.1; + } + + {{- with .Values.gateway.nginxConfig.serverSnippet }} + {{ . | nindent 4 }} + {{- end }} + } + } + + loki: + # image: + # registry: + # repository: grafana/loki + # tag: 2.9.2 + podAnnotations: + sidecar.istio.io/inject: "false" + storageConfig: + aws: + s3: http://minio:minio123@monitoring-minio.monitoring.svc:9000/loki + s3forcepathstyle: true + region: us-east-1 + # aws: + # region: ap-south-1 + # bucketnames: jm-prod-loki-app-logs + # s3forcepathstyle: false + # sse_encryption: true + boltdb_shipper: + shared_store: s3 + cache_ttl: 24h + schemaConfig: + configs: + - from: "2020-09-07" + store: boltdb-shipper + object_store: s3 + schema: v11 + index: + prefix: loki_index_ + period: 24h + config: | + auth_enabled: false + + server: + {{- toYaml .Values.loki.server | nindent 6 }} + + common: + compactor_address: http://{{ include "loki.compactorFullname" . }}:3100 + + distributor: + ring: + kvstore: + store: memberlist + + memberlist: + join_members: + - {{ include "loki.fullname" . }}-memberlist + + ingester_client: + grpc_client_config: + grpc_compression: gzip + + ingester: + lifecycler: + ring: + kvstore: + store: memberlist + replication_factor: 1 + chunk_idle_period: 30m + chunk_block_size: 262144 + chunk_encoding: snappy + chunk_retain_period: 1m + max_transfer_retries: 0 + wal: + dir: /var/loki/wal + + limits_config: + retention_period: 72h + enforce_metric_name: false + reject_old_samples: true + reject_old_samples_max_age: 168h + max_cache_freshness_per_query: 10m + split_queries_by_interval: 15m + # for big logs tune + per_stream_rate_limit: 512M + per_stream_rate_limit_burst: 1024M + cardinality_limit: 200000 + ingestion_burst_size_mb: 1000 + ingestion_rate_mb: 10000 + max_entries_limit_per_query: 1000000 + max_label_value_length: 20480 + max_label_name_length: 10240 + max_label_names_per_series: 300 + + {{- if .Values.loki.schemaConfig}} + schema_config: + {{- toYaml .Values.loki.schemaConfig | nindent 2}} + {{- end}} + {{- if .Values.loki.storageConfig}} + storage_config: + {{- if .Values.indexGateway.enabled}} + {{- $indexGatewayClient := dict "server_address" (printf "dns:///%s:9095" (include "loki.indexGatewayFullname" .)) }} + {{- $_ := set .Values.loki.storageConfig.boltdb_shipper "index_gateway_client" $indexGatewayClient }} + {{- end}} + {{- toYaml .Values.loki.storageConfig | nindent 2}} + {{- if .Values.memcachedIndexQueries.enabled }} + index_queries_cache_config: + memcached_client: + addresses: dnssrv+_memcached-client._tcp.{{ include "loki.memcachedIndexQueriesFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }} + consistent_hash: true + {{- end}} + {{- end}} + + runtime_config: + file: /var/{{ include "loki.name" . }}-runtime/runtime.yaml + + chunk_store_config: + max_look_back_period: 0s + {{- if .Values.memcachedChunks.enabled }} + chunk_cache_config: + embedded_cache: + enabled: false + memcached_client: + consistent_hash: true + addresses: dnssrv+_memcached-client._tcp.{{ include "loki.memcachedChunksFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }} + {{- end }} + {{- if .Values.memcachedIndexWrites.enabled }} + write_dedupe_cache_config: + memcached_client: + consistent_hash: true + addresses: dnssrv+_memcached-client._tcp.{{ include "loki.memcachedIndexWritesFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }} + {{- end }} + + table_manager: + retention_deletes_enabled: false + retention_period: 0s + + query_range: + align_queries_with_step: true + max_retries: 5 + cache_results: true + results_cache: + cache: + {{- if .Values.memcachedFrontend.enabled }} + memcached_client: + addresses: dnssrv+_memcached-client._tcp.{{ include "loki.memcachedFrontendFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }} + consistent_hash: true + {{- else }} + embedded_cache: + enabled: true + ttl: 24h + {{- end }} + + frontend_worker: + {{- if .Values.queryScheduler.enabled }} + scheduler_address: {{ include "loki.querySchedulerFullname" . }}:9095 + {{- else }} + frontend_address: {{ include "loki.queryFrontendFullname" . }}-headless:9095 + {{- end }} + + frontend: + log_queries_longer_than: 5s + compress_responses: true + {{- if .Values.queryScheduler.enabled }} + scheduler_address: {{ include "loki.querySchedulerFullname" . }}:9095 + {{- end }} + tail_proxy_url: http://{{ include "loki.querierFullname" . }}:3100 + + compactor: + working_directory: /tml/loki/compactor + shared_store: s3 + compaction_interval: 2m + retention_enabled: false + + ruler: + storage: + type: local + local: + directory: /etc/loki/rules + ring: + kvstore: + store: memberlist + rule_path: /tmp/loki/scratch + alertmanager_url: https://alertmanager.xx + external_url: https://alertmanager.xx + + serviceAccount: + create: true + name: loki-sa + imagePullSecrets: [] + labels: {} + annotations: + eks.amazonaws.com/role-arn: arn:aws:iam::913108190184:role/jm-prod-fluent + automountServiceAccountToken: true + + compactor: + enabled: true + retention_enabled: true + shared_store: s3 + # nodeSelector: + # appType: monitoring + # tolerations: + # - key: "appType" + # operator: "Equal" + # value: "monitoring" + # effect: "NoSchedule" + + queryFrontend: + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 2 + resources: + requests: + memory: 500Mi + cpu: 200m + limits: + memory: 500Mi + cpu: 200m + distributor: + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 2 + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + + ingester: + replicas: 2 + maxUnavailable: 1 + persistence: + enabled: true + claims: + - name: data + size: 1Gi + # storageClass: encrypted-gp3 + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + # nodeSelector: + # appType: monitoring + # tolerations: + # - key: "appType" + # operator: "Equal" + # value: "monitoring" + # effect: "NoSchedule" + # affinity: "" + + querier: + kind: Deployment + replicas: 1 + maxUnavailable: 1 + # persistence: + # enabled: true + # size: 10Gi + # storageClass: encrypted-gp3 + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 2 + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + + memcachedChunks: + enabled: true + replicas: 1 + maxUnavailable: 1 + persistence: + enabled: true + size: 1Gi + # storageClass: encrypted-gp3 + extraArgs: + - -m 2048 + - -I 32m + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + + memcachedFrontend: + enabled: true + replicas: 1 + maxUnavailable: 1 + persistence: + enabled: true + size: 1Gi + # storageClass: encrypted-gp3 + extraArgs: + - -m 2048 + - -I 32m + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + + memcachedIndexQueries: + enabled: true + replicas: 1 + maxUnavailable: 1 + persistence: + enabled: true + size: 1Gi + # storageClass: encrypted-gp3 + extraArgs: + - -m 2048 + - -I 32m + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + + indexGateway: + enabled: true + replicas: 2 + maxUnavailable: 1 + persistence: + enabled: true + size: 1Gi + # storageClass: encrypted-gp3 + resources: + requests: + cpu: 200m + memory: 500Mi + limits: + cpu: 200m + memory: 500Mi + + # serviceMonitor: + # enabled: true + # namespace: logging + # namespaceSelector: + # any: true + # labels: + # prometheus: kube + + # prometheusRule: + # enabled: false + # namespace: logging + # annotations: {} + # labels: + # app: loki-kube-prometheus + # prometheus: kube + # groups: [] + +promtail: + config: + logLevel: info + clients: + - url: http://loki-logging-gateway.logging.svc.cluster.local/loki/api/v1/push \ No newline at end of file diff --git a/charts/loki/scalable/Chart.lock b/charts/loki/scalable/Chart.lock new file mode 100644 index 00000000..1223d25c --- /dev/null +++ b/charts/loki/scalable/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: loki + repository: https://grafana.github.io/helm-charts + version: 6.7.3 +- name: promtail + repository: https://grafana.github.io/helm-charts + version: 6.16.4 +digest: sha256:e2862ad61dc8ef8b2c579ea62e4e80f5bdeeb4f178f2b7f6654076632eccbb40 +generated: "2024-08-01T10:08:34.492754+05:30" diff --git a/charts/loki/scalable/Chart.yaml b/charts/loki/scalable/Chart.yaml new file mode 100644 index 00000000..0ffe053c --- /dev/null +++ b/charts/loki/scalable/Chart.yaml @@ -0,0 +1,19 @@ +apiVersion: v2 +name: loki +description: A Helm chart for Simple Scalable loki +type: application +version: 0.1.0 +appVersion: 1.0.0 +dependencies: + - name: loki + version: 6.7.3 + repository: https://grafana.github.io/helm-charts + alias: logging + tags: + - logging + - name: promtail + version: 6.16.4 + repository: https://grafana.github.io/helm-charts + alias: promtail + tags: + - logging diff --git a/charts/loki/scalable/values.yaml b/charts/loki/scalable/values.yaml new file mode 100644 index 00000000..3e19bf48 --- /dev/null +++ b/charts/loki/scalable/values.yaml @@ -0,0 +1,86 @@ +logging: + loki: + storage: + type: filesystem + auth_enabled: false + commonConfig: + replication_factor: 1 + schemaConfig: + configs: + - from: 2024-04-01 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: loki_index_ + period: 24h + ingester: + chunk_encoding: snappy + tracing: + enabled: true + querier: + # Default is 4, if you have enough memory and CPU you can increase, reduce if OOMing + max_concurrent: 2 + + deploymentMode: SingleBinary + lokiCanary: + enabled: false + test: + enabled: false + singleBinary: + replicas: 1 + resources: + limits: + cpu: 3 + memory: 4Gi + requests: + cpu: 2 + memory: 2Gi + extraEnv: + # Keep a little bit lower than memory limits + - name: GOMEMLIMIT + value: 3750MiB + + chunksCache: + # default is 500MB, with limited memory keep this smaller + writebackSizeLimit: 10MB + allocatedMemory: 1024 + + # Enable minio for storage + minio: + enabled: false + persistence: + size: 10Gi + + # Zero out replica counts of other deployment modes + backend: + replicas: 0 + read: + replicas: 0 + write: + replicas: 0 + + ingester: + replicas: 0 + querier: + replicas: 0 + queryFrontend: + replicas: 0 + queryScheduler: + replicas: 0 + distributor: + replicas: 0 + compactor: + replicas: 0 + indexGateway: + replicas: 0 + bloomCompactor: + replicas: 0 + bloomGateway: + replicas: 0 + +promtail: + config: + logLevel: info + clients: + - url: http://logging-gateway/loki/api/v1/push \ No newline at end of file diff --git a/charts/loki/values.yaml b/charts/loki/values.yaml new file mode 100644 index 00000000..684592e9 --- /dev/null +++ b/charts/loki/values.yaml @@ -0,0 +1,90 @@ +distributed: + enabled: false + +standalone: + enabled: true + loki: + storage: + type: filesystem + auth_enabled: false + commonConfig: + replication_factor: 1 + schemaConfig: + configs: + - from: 2024-04-01 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: loki_index_ + period: 24h + ingester: + chunk_encoding: snappy + tracing: + enabled: true + querier: + # Default is 4, if you have enough memory and CPU you can increase, reduce if OOMing + max_concurrent: 2 + + deploymentMode: SingleBinary + lokiCanary: + enabled: false + test: + enabled: false + singleBinary: + replicas: 1 + resources: + limits: + cpu: 3 + memory: 4Gi + requests: + cpu: 2 + memory: 2Gi + extraEnv: + # Keep a little bit lower than memory limits + - name: GOMEMLIMIT + value: 3750MiB + + chunksCache: + # default is 500MB, with limited memory keep this smaller + writebackSizeLimit: 10MB + allocatedMemory: 1024 + + # Enable minio for storage + minio: + enabled: false + persistence: + size: 10Gi + + # Zero out replica counts of other deployment modes + backend: + replicas: 0 + read: + replicas: 0 + write: + replicas: 0 + + ingester: + replicas: 0 + querier: + replicas: 0 + queryFrontend: + replicas: 0 + queryScheduler: + replicas: 0 + distributor: + replicas: 0 + compactor: + replicas: 0 + indexGateway: + replicas: 0 + bloomCompactor: + replicas: 0 + bloomGateway: + replicas: 0 + +promtail: + config: + logLevel: info + clients: + - url: http://logging-gateway/loki/api/v1/push \ No newline at end of file diff --git a/charts/pga/templates/datasources/loki.yaml b/charts/pga/templates/datasources/loki.yaml index b8efa56c..fc87b5ad 100644 --- a/charts/pga/templates/datasources/loki.yaml +++ b/charts/pga/templates/datasources/loki.yaml @@ -11,9 +11,9 @@ data: kube-loki.yaml: |- apiVersion: 1 datasources: - - uid: loki + - uid: logging orgId: 1 - name: Loki + name: logging type: loki typeName: Loki access: proxy