loki.yaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. ---
  2. # Source: loki-stack/charts/loki/templates/serviceaccount.yaml
  3. apiVersion: v1
  4. kind: ServiceAccount
  5. metadata:
  6. labels:
  7. app: loki
  8. chart: loki-2.16.0
  9. release: loki
  10. heritage: Helm
  11. annotations:
  12. {}
  13. name: loki
  14. namespace: default
  15. automountServiceAccountToken: true
  16. ---
  17. # Source: loki-stack/charts/promtail/templates/serviceaccount.yaml
  18. apiVersion: v1
  19. kind: ServiceAccount
  20. metadata:
  21. name: loki-promtail
  22. namespace: default
  23. labels:
  24. helm.sh/chart: promtail-6.7.4
  25. app.kubernetes.io/name: promtail
  26. app.kubernetes.io/instance: loki
  27. app.kubernetes.io/version: "2.7.0"
  28. app.kubernetes.io/managed-by: Helm
  29. ---
  30. # Source: loki-stack/charts/loki/templates/secret.yaml
  31. apiVersion: v1
  32. kind: Secret
  33. metadata:
  34. name: loki
  35. namespace: default
  36. labels:
  37. app: loki
  38. chart: loki-2.16.0
  39. release: loki
  40. heritage: Helm
  41. data:
  42. loki.yaml: YXV0aF9lbmFibGVkOiBmYWxzZQpjaHVua19zdG9yZV9jb25maWc6CiAgbWF4X2xvb2tfYmFja19wZXJpb2Q6IDBzCmNvbXBhY3RvcjoKICBzaGFyZWRfc3RvcmU6IGZpbGVzeXN0ZW0KICB3b3JraW5nX2RpcmVjdG9yeTogL2RhdGEvbG9raS9ib2x0ZGItc2hpcHBlci1jb21wYWN0b3IKaW5nZXN0ZXI6CiAgY2h1bmtfYmxvY2tfc2l6ZTogMjYyMTQ0CiAgY2h1bmtfaWRsZV9wZXJpb2Q6IDNtCiAgY2h1bmtfcmV0YWluX3BlcmlvZDogMW0KICBsaWZlY3ljbGVyOgogICAgcmluZzoKICAgICAgcmVwbGljYXRpb25fZmFjdG9yOiAxCiAgbWF4X3RyYW5zZmVyX3JldHJpZXM6IDAKICB3YWw6CiAgICBkaXI6IC9kYXRhL2xva2kvd2FsCmxpbWl0c19jb25maWc6CiAgZW5mb3JjZV9tZXRyaWNfbmFtZTogZmFsc2UKICBtYXhfZW50cmllc19saW1pdF9wZXJfcXVlcnk6IDUwMDAKICByZWplY3Rfb2xkX3NhbXBsZXM6IHRydWUKICByZWplY3Rfb2xkX3NhbXBsZXNfbWF4X2FnZTogMTY4aAptZW1iZXJsaXN0OgogIGpvaW5fbWVtYmVyczoKICAtICdsb2tpLW1lbWJlcmxpc3QnCnNjaGVtYV9jb25maWc6CiAgY29uZmlnczoKICAtIGZyb206ICIyMDIwLTEwLTI0IgogICAgaW5kZXg6CiAgICAgIHBlcmlvZDogMjRoCiAgICAgIHByZWZpeDogaW5kZXhfCiAgICBvYmplY3Rfc3RvcmU6IGZpbGVzeXN0ZW0KICAgIHNjaGVtYTogdjExCiAgICBzdG9yZTogYm9sdGRiLXNoaXBwZXIKc2VydmVyOgogIGdycGNfbGlzdGVuX3BvcnQ6IDkwOTUKICBodHRwX2xpc3Rlbl9wb3J0OiAzMTAwCnN0b3JhZ2VfY29uZmlnOgogIGJvbHRkYl9zaGlwcGVyOgogICAgYWN0aXZlX2luZGV4X2RpcmVjdG9yeTogL2RhdGEvbG9raS9ib2x0ZGItc2hpcHBlci1hY3RpdmUKICAgIGNhY2hlX2xvY2F0aW9uOiAvZGF0YS9sb2tpL2JvbHRkYi1zaGlwcGVyLWNhY2hlCiAgICBjYWNoZV90dGw6IDI0aAogICAgc2hhcmVkX3N0b3JlOiBmaWxlc3lzdGVtCiAgZmlsZXN5c3RlbToKICAgIGRpcmVjdG9yeTogL2RhdGEvbG9raS9jaHVua3MKdGFibGVfbWFuYWdlcjoKICByZXRlbnRpb25fZGVsZXRlc19lbmFibGVkOiBmYWxzZQogIHJldGVudGlvbl9wZXJpb2Q6IDBz
  43. ---
  44. # Source: loki-stack/charts/promtail/templates/secret.yaml
  45. apiVersion: v1
  46. kind: Secret
  47. metadata:
  48. name: loki-promtail
  49. namespace: default
  50. labels:
  51. helm.sh/chart: promtail-6.7.4
  52. app.kubernetes.io/name: promtail
  53. app.kubernetes.io/instance: loki
  54. app.kubernetes.io/version: "2.7.0"
  55. app.kubernetes.io/managed-by: Helm
  56. stringData:
  57. promtail.yaml: |
  58. server:
  59. log_level: info
  60. http_listen_port: 3101
  61. clients:
  62. - url: http://loki:3100/loki/api/v1/push
  63. positions:
  64. filename: /run/promtail/positions.yaml
  65. scrape_configs:
  66. # See also https://github.com/grafana/loki/blob/master/production/ksonnet/promtail/scrape_config.libsonnet for reference
  67. - job_name: kubernetes-pods
  68. pipeline_stages:
  69. - cri: {}
  70. kubernetes_sd_configs:
  71. - role: pod
  72. relabel_configs:
  73. - source_labels:
  74. - __meta_kubernetes_pod_controller_name
  75. regex: ([0-9a-z-.]+?)(-[0-9a-f]{8,10})?
  76. action: replace
  77. target_label: __tmp_controller_name
  78. - source_labels:
  79. - __meta_kubernetes_pod_label_app_kubernetes_io_name
  80. - __meta_kubernetes_pod_label_app
  81. - __tmp_controller_name
  82. - __meta_kubernetes_pod_name
  83. regex: ^;*([^;]+)(;.*)?$
  84. action: replace
  85. target_label: app
  86. - source_labels:
  87. - __meta_kubernetes_pod_label_app_kubernetes_io_instance
  88. - __meta_kubernetes_pod_label_release
  89. regex: ^;*([^;]+)(;.*)?$
  90. action: replace
  91. target_label: instance
  92. - source_labels:
  93. - __meta_kubernetes_pod_label_app_kubernetes_io_component
  94. - __meta_kubernetes_pod_label_component
  95. regex: ^;*([^;]+)(;.*)?$
  96. action: replace
  97. target_label: component
  98. - action: replace
  99. source_labels:
  100. - __meta_kubernetes_pod_node_name
  101. target_label: node_name
  102. - action: replace
  103. source_labels:
  104. - __meta_kubernetes_namespace
  105. target_label: namespace
  106. - action: replace
  107. replacement: $1
  108. separator: /
  109. source_labels:
  110. - namespace
  111. - app
  112. target_label: job
  113. - action: replace
  114. source_labels:
  115. - __meta_kubernetes_pod_name
  116. target_label: pod
  117. - action: replace
  118. source_labels:
  119. - __meta_kubernetes_pod_container_name
  120. target_label: container
  121. - action: replace
  122. replacement: /var/log/pods/*$1/*.log
  123. separator: /
  124. source_labels:
  125. - __meta_kubernetes_pod_uid
  126. - __meta_kubernetes_pod_container_name
  127. target_label: __path__
  128. - action: replace
  129. regex: true/(.*)
  130. replacement: /var/log/pods/*$1/*.log
  131. separator: /
  132. source_labels:
  133. - __meta_kubernetes_pod_annotationpresent_kubernetes_io_config_hash
  134. - __meta_kubernetes_pod_annotation_kubernetes_io_config_hash
  135. - __meta_kubernetes_pod_container_name
  136. target_label: __path__
  137. limits_config:
  138. ---
  139. # Source: loki-stack/templates/datasources.yaml
  140. apiVersion: v1
  141. kind: ConfigMap
  142. metadata:
  143. name: loki-loki-stack
  144. namespace: default
  145. labels:
  146. app: loki-stack
  147. chart: loki-stack-2.8.9
  148. release: loki
  149. heritage: Helm
  150. grafana_datasource: "1"
  151. data:
  152. loki-stack-datasource.yaml: |-
  153. apiVersion: 1
  154. datasources:
  155. - name: Loki
  156. type: loki
  157. access: proxy
  158. url: "http://loki:3100"
  159. version: 1
  160. isDefault: true
  161. jsonData:
  162. {}
  163. ---
  164. # Source: loki-stack/templates/tests/loki-test-configmap.yaml
  165. apiVersion: v1
  166. kind: ConfigMap
  167. metadata:
  168. name: loki-loki-stack-test
  169. labels:
  170. app: loki-stack
  171. chart: loki-stack-2.8.9
  172. release: loki
  173. heritage: Helm
  174. data:
  175. test.sh: |
  176. #!/usr/bin/env bash
  177. LOKI_URI="http://${LOKI_SERVICE}:${LOKI_PORT}"
  178. function setup() {
  179. apk add -u curl jq
  180. until (curl -s ${LOKI_URI}/loki/api/v1/label/app/values | jq -e '.data[] | select(. == "loki")'); do
  181. sleep 1
  182. done
  183. }
  184. @test "Has labels" {
  185. curl -s ${LOKI_URI}/loki/api/v1/labels | \
  186. jq -e '.data[] | select(. == "app")'
  187. }
  188. @test "Query log entry" {
  189. curl -sG ${LOKI_URI}/api/prom/query?limit=10 --data-urlencode 'query={app="loki"}' | \
  190. jq -e '.streams[].entries | length >=1'
  191. }
  192. @test "Push log entry" {
  193. local timestamp=$(date +%s000000000)
  194. local data=$(jq -n --arg timestamp "${timestamp}" '{"streams": [{"stream": {"app": "loki-test"}, "values": [[$timestamp, "foobar"]]}]}')
  195. curl -s -X POST -H "Content-Type: application/json" ${LOKI_URI}/loki/api/v1/push --data-raw "${data}"
  196. curl -sG ${LOKI_URI}/loki/api/v1/query_range?limit=1 --data-urlencode 'query={app="loki-test"}' | \
  197. jq -e '.data.result[].values[][1] == "foobar"'
  198. }
  199. ---
  200. # Source: loki-stack/charts/promtail/templates/clusterrole.yaml
  201. kind: ClusterRole
  202. apiVersion: rbac.authorization.k8s.io/v1
  203. metadata:
  204. name: loki-promtail
  205. labels:
  206. helm.sh/chart: promtail-6.7.4
  207. app.kubernetes.io/name: promtail
  208. app.kubernetes.io/instance: loki
  209. app.kubernetes.io/version: "2.7.0"
  210. app.kubernetes.io/managed-by: Helm
  211. rules:
  212. - apiGroups:
  213. - ""
  214. resources:
  215. - nodes
  216. - nodes/proxy
  217. - services
  218. - endpoints
  219. - pods
  220. verbs:
  221. - get
  222. - watch
  223. - list
  224. ---
  225. # Source: loki-stack/charts/promtail/templates/clusterrolebinding.yaml
  226. kind: ClusterRoleBinding
  227. apiVersion: rbac.authorization.k8s.io/v1
  228. metadata:
  229. name: loki-promtail
  230. labels:
  231. helm.sh/chart: promtail-6.7.4
  232. app.kubernetes.io/name: promtail
  233. app.kubernetes.io/instance: loki
  234. app.kubernetes.io/version: "2.7.0"
  235. app.kubernetes.io/managed-by: Helm
  236. subjects:
  237. - kind: ServiceAccount
  238. name: loki-promtail
  239. namespace: default
  240. roleRef:
  241. kind: ClusterRole
  242. name: loki-promtail
  243. apiGroup: rbac.authorization.k8s.io
  244. ---
  245. # Source: loki-stack/charts/loki/templates/role.yaml
  246. apiVersion: rbac.authorization.k8s.io/v1
  247. kind: Role
  248. metadata:
  249. name: loki
  250. namespace: default
  251. labels:
  252. app: loki
  253. chart: loki-2.16.0
  254. release: loki
  255. heritage: Helm
  256. rules:
  257. - apiGroups: ['extensions']
  258. resources: ['podsecuritypolicies']
  259. verbs: ['use']
  260. resourceNames: [loki]
  261. ---
  262. # Source: loki-stack/charts/loki/templates/rolebinding.yaml
  263. apiVersion: rbac.authorization.k8s.io/v1
  264. kind: RoleBinding
  265. metadata:
  266. name: loki
  267. namespace: default
  268. labels:
  269. app: loki
  270. chart: loki-2.16.0
  271. release: loki
  272. heritage: Helm
  273. roleRef:
  274. apiGroup: rbac.authorization.k8s.io
  275. kind: Role
  276. name: loki
  277. subjects:
  278. - kind: ServiceAccount
  279. name: loki
  280. ---
  281. # Source: loki-stack/charts/loki/templates/service-headless.yaml
  282. apiVersion: v1
  283. kind: Service
  284. metadata:
  285. name: loki-headless
  286. namespace: default
  287. labels:
  288. app: loki
  289. chart: loki-2.16.0
  290. release: loki
  291. heritage: Helm
  292. variant: headless
  293. spec:
  294. clusterIP: None
  295. ports:
  296. - port: 3100
  297. protocol: TCP
  298. name: http-metrics
  299. targetPort: http-metrics
  300. selector:
  301. app: loki
  302. release: loki
  303. ---
  304. # Source: loki-stack/charts/loki/templates/service-memberlist.yaml
  305. apiVersion: v1
  306. kind: Service
  307. metadata:
  308. name: loki-memberlist
  309. namespace: default
  310. labels:
  311. app: loki
  312. chart: loki-2.16.0
  313. release: loki
  314. heritage: Helm
  315. spec:
  316. type: ClusterIP
  317. clusterIP: None
  318. publishNotReadyAddresses: true
  319. ports:
  320. - name: http
  321. port: 7946
  322. targetPort: memberlist-port
  323. protocol: TCP
  324. selector:
  325. app: loki
  326. release: loki
  327. ---
  328. # Source: loki-stack/charts/loki/templates/service.yaml
  329. apiVersion: v1
  330. kind: Service
  331. metadata:
  332. name: loki
  333. namespace: default
  334. labels:
  335. app: loki
  336. chart: loki-2.16.0
  337. release: loki
  338. heritage: Helm
  339. annotations:
  340. {}
  341. spec:
  342. type: ClusterIP
  343. ports:
  344. - port: 3100
  345. protocol: TCP
  346. name: http-metrics
  347. targetPort: http-metrics
  348. selector:
  349. app: loki
  350. release: loki
  351. ---
  352. # Source: loki-stack/charts/promtail/templates/daemonset.yaml
  353. apiVersion: apps/v1
  354. kind: DaemonSet
  355. metadata:
  356. name: loki-promtail
  357. namespace: default
  358. labels:
  359. helm.sh/chart: promtail-6.7.4
  360. app.kubernetes.io/name: promtail
  361. app.kubernetes.io/instance: loki
  362. app.kubernetes.io/version: "2.7.0"
  363. app.kubernetes.io/managed-by: Helm
  364. spec:
  365. selector:
  366. matchLabels:
  367. app.kubernetes.io/name: promtail
  368. app.kubernetes.io/instance: loki
  369. updateStrategy:
  370. {}
  371. template:
  372. metadata:
  373. labels:
  374. app.kubernetes.io/name: promtail
  375. app.kubernetes.io/instance: loki
  376. annotations:
  377. checksum/config: d566bf766424f0ee767a237d2b599c0f88b3129f45721acdb2f519024885cd31
  378. spec:
  379. serviceAccountName: loki-promtail
  380. enableServiceLinks: true
  381. securityContext:
  382. runAsGroup: 0
  383. runAsUser: 0
  384. containers:
  385. - name: promtail
  386. image: "docker.io/grafana/promtail:2.7.0"
  387. imagePullPolicy: IfNotPresent
  388. args:
  389. - "-config.file=/etc/promtail/promtail.yaml"
  390. volumeMounts:
  391. - name: config
  392. mountPath: /etc/promtail
  393. - mountPath: /run/promtail
  394. name: run
  395. - mountPath: /var/lib/docker/containers
  396. name: containers
  397. readOnly: true
  398. - mountPath: /var/log/pods
  399. name: pods
  400. readOnly: true
  401. env:
  402. - name: HOSTNAME
  403. valueFrom:
  404. fieldRef:
  405. fieldPath: spec.nodeName
  406. ports:
  407. - name: http-metrics
  408. containerPort: 3101
  409. protocol: TCP
  410. securityContext:
  411. allowPrivilegeEscalation: false
  412. capabilities:
  413. drop:
  414. - ALL
  415. readOnlyRootFilesystem: true
  416. readinessProbe:
  417. failureThreshold: 5
  418. httpGet:
  419. path: '/ready'
  420. port: http-metrics
  421. initialDelaySeconds: 10
  422. periodSeconds: 10
  423. successThreshold: 1
  424. timeoutSeconds: 1
  425. tolerations:
  426. - effect: NoSchedule
  427. key: node-role.kubernetes.io/master
  428. operator: Exists
  429. - effect: NoSchedule
  430. key: node-role.kubernetes.io/control-plane
  431. operator: Exists
  432. volumes:
  433. - name: config
  434. secret:
  435. secretName: loki-promtail
  436. - hostPath:
  437. path: /run/promtail
  438. name: run
  439. - hostPath:
  440. path: /var/lib/docker/containers
  441. name: containers
  442. - hostPath:
  443. path: /var/log/pods
  444. name: pods
  445. ---
  446. # Source: loki-stack/charts/loki/templates/statefulset.yaml
  447. apiVersion: apps/v1
  448. kind: StatefulSet
  449. metadata:
  450. name: loki
  451. namespace: default
  452. labels:
  453. app: loki
  454. chart: loki-2.16.0
  455. release: loki
  456. heritage: Helm
  457. annotations:
  458. {}
  459. spec:
  460. podManagementPolicy: OrderedReady
  461. replicas: 1
  462. selector:
  463. matchLabels:
  464. app: loki
  465. release: loki
  466. serviceName: loki-headless
  467. updateStrategy:
  468. type: RollingUpdate
  469. template:
  470. metadata:
  471. labels:
  472. app: loki
  473. name: loki
  474. release: loki
  475. annotations:
  476. checksum/config: 70f817aa5a2dd5f771aca66233ce0b140c925212f36795fdeb95102ca96db046
  477. prometheus.io/port: http-metrics
  478. prometheus.io/scrape: "true"
  479. spec:
  480. serviceAccountName: loki
  481. securityContext:
  482. fsGroup: 10001
  483. runAsGroup: 10001
  484. runAsNonRoot: true
  485. runAsUser: 10001
  486. initContainers:
  487. []
  488. containers:
  489. - name: loki
  490. image: "grafana/loki:2.6.1"
  491. imagePullPolicy: IfNotPresent
  492. args:
  493. - "-config.file=/etc/loki/loki.yaml"
  494. volumeMounts:
  495. - name: tmp
  496. mountPath: /tmp
  497. - name: config
  498. mountPath: /etc/loki
  499. - name: storage
  500. mountPath: "/data"
  501. subPath:
  502. ports:
  503. - name: http-metrics
  504. containerPort: 3100
  505. protocol: TCP
  506. - name: grpc
  507. containerPort: 9095
  508. protocol: TCP
  509. - name: memberlist-port
  510. containerPort: 7946
  511. protocol: TCP
  512. livenessProbe:
  513. httpGet:
  514. path: /ready
  515. port: http-metrics
  516. initialDelaySeconds: 45
  517. readinessProbe:
  518. httpGet:
  519. path: /ready
  520. port: http-metrics
  521. initialDelaySeconds: 45
  522. resources:
  523. {}
  524. securityContext:
  525. readOnlyRootFilesystem: true
  526. env:
  527. nodeSelector:
  528. {}
  529. affinity:
  530. {}
  531. tolerations:
  532. []
  533. terminationGracePeriodSeconds: 4800
  534. volumes:
  535. - name: tmp
  536. emptyDir: {}
  537. - name: config
  538. secret:
  539. secretName: loki
  540. - name: storage
  541. emptyDir: {}
  542. ---
  543. # Source: loki-stack/templates/tests/loki-test-pod.yaml
  544. apiVersion: v1
  545. kind: Pod
  546. metadata:
  547. annotations:
  548. "helm.sh/hook": test-success
  549. labels:
  550. app: loki-stack
  551. chart: loki-stack-2.8.9
  552. release: loki
  553. heritage: Helm
  554. name: loki-loki-stack-test
  555. spec:
  556. containers:
  557. - name: test
  558. image: "bats/bats:v1.1.0"
  559. imagePullPolicy: ""
  560. args:
  561. - /var/lib/loki/test.sh
  562. env:
  563. - name: LOKI_SERVICE
  564. value: loki
  565. - name: LOKI_PORT
  566. value: "3100"
  567. volumeMounts:
  568. - name: tests
  569. mountPath: /var/lib/loki
  570. restartPolicy: Never
  571. volumes:
  572. - name: tests
  573. configMap:
  574. name: loki-loki-stack-test