diff --git a/grafana/datasource.yml b/grafana/datasource.yml index 20285e4..36cc39a 100644 --- a/grafana/datasource.yml +++ b/grafana/datasource.yml @@ -1,12 +1,16 @@ +# config file version apiVersion: 1 +deleteDatasources: + - name: loki + datasources: - - name: Loki - type: loki - access: proxy - url: http://loki:3100 - editable: false - jsonData: - httpHeaderName1: "X-Scope-OrgID" - secureJsonData: - httpHeaderValue1: "tenant1" +- name: loki + type: loki + access: proxy + orgId: 1 + url: http://loki:3100 + basicAuth: false + isDefault: true + version: 1 + editable: false diff --git a/grafana/docker-compose.yaml b/grafana/docker-compose.yaml index 9f6f584..07a2ffd 100644 --- a/grafana/docker-compose.yaml +++ b/grafana/docker-compose.yaml @@ -1,71 +1,43 @@ ---- -version: "3" - -networks: - loki: +version: "3.4" services: - loki: - image: grafana/loki:2.8.2 + my-nginx-service: + image: nginx + container_name: my-nginx-service ports: - - 3101:3100 - volumes: - - ./loki-config.yaml:/etc/loki/config.yaml - depends_on: - - minio - healthcheck: - test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ] - interval: 10s - timeout: 5s - retries: 5 - - minio: - image: minio/minio - entrypoint: - - sh - - -euc - - | - mkdir -p /data/loki-data && \ - mkdir -p /data/loki-ruler && \ - minio server /data + - 8000:80 environment: - - MINIO_ROOT_USER=loki - - MINIO_ROOT_PASSWORD=supersecret - - MINIO_PROMETHEUS_AUTH_TYPE=public - - MINIO_UPDATE=off - ports: - - 9000 - volumes: - - ./.data/minio:/data - healthcheck: - test: [ "CMD", "curl", "-f", "http://localhost:9000/minio/health/live" ] - interval: 15s - timeout: 20s - retries: 5 - networks: - - loki - - grafana: - image: grafana/grafana:latest - environment: - - GF_PATHS_PROVISIONING=/etc/grafana/provisioning - - GF_AUTH_ANONYMOUS_ENABLED=true - - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - volumes: - - ./datasource.yml:/etc/grafana/provisioning/datasources/ds.yml - ports: - - "3000:3000" - healthcheck: - test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1" ] - interval: 10s - timeout: 5s - retries: 5 - - flog: - image: mingrammer/flog - command: -f json -d 1s -l + - FOO=bar logging: driver: loki options: - loki-url: http://localhost:3100/loki/api/v1/push - loki-external-labels: job=dockerlogs,owner=ruan,environment=development + loki-url: http://loki:3100/loki/api/v1/push + loki-external-labels: job=dockerlogs,environment=development + + grafana: + image: grafana/grafana:7.2.2 + container_name: grafana + volumes: + - ./datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml + ports: + - "3000:3000" + + loki: + image: grafana/loki:2.8.2 + container_name: loki + volumes: + - ./loki.yaml:/etc/config/loki.yaml + entrypoint: + - /usr/bin/loki + - -config.file=/etc/config/loki.yaml + ports: + - "3100:3100" + + logger-app: + image: mingrammer/flog + container_name: logger + logging: + driver: loki + options: + loki-url: http://loki:3100/loki/api/v1/push + loki-external-labels: job=dockerlogs,environment=development diff --git a/grafana/loki-config.yaml b/grafana/loki-config.yaml deleted file mode 100644 index 775db58..0000000 --- a/grafana/loki-config.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -server: - http_listen_port: 3100 -memberlist: - join_members: - - loki:7946 -schema_config: - configs: - - from: 2021-08-01 - store: boltdb-shipper - object_store: s3 - schema: v11 - index: - prefix: index_ - period: 24h -common: - path_prefix: /loki - replication_factor: 1 - storage: - s3: - endpoint: minio:9000 - insecure: true - bucketnames: loki-data - access_key_id: loki - secret_access_key: supersecret - s3forcepathstyle: true - ring: - kvstore: - store: memberlist -ruler: - storage: - s3: - bucketnames: loki-ruler diff --git a/grafana/loki.yaml b/grafana/loki.yaml new file mode 100644 index 0000000..bba0fe3 --- /dev/null +++ b/grafana/loki.yaml @@ -0,0 +1,54 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + +ingester: + lifecycler: + address: 127.0.0.1 + ring: + kvstore: + store: inmemory + replication_factor: 1 + final_sleep: 0s + chunk_idle_period: 5m + chunk_retain_period: 30s + +schema_config: + configs: + - from: 2018-04-15 + store: boltdb + object_store: filesystem + schema: v9 + index: + prefix: index_ + period: 168h + +storage_config: + boltdb: + directory: /tmp/loki/index + + filesystem: + directory: /tmp/loki/chunks + +limits_config: + enforce_metric_name: false + reject_old_samples: true + reject_old_samples_max_age: 168h + +chunk_store_config: + max_look_back_period: 0 + +table_manager: + chunk_tables_provisioning: + inactive_read_throughput: 0 + inactive_write_throughput: 0 + provisioned_read_throughput: 0 + provisioned_write_throughput: 0 + index_tables_provisioning: + inactive_read_throughput: 0 + inactive_write_throughput: 0 + provisioned_read_throughput: 0 + provisioned_write_throughput: 0 + retention_deletes_enabled: false + retention_period: 0 diff --git a/grafana/promtail-local-config.yaml b/grafana/promtail-local-config.yaml deleted file mode 100644 index dcb2d3e..0000000 --- a/grafana/promtail-local-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -server: - http_listen_port: 9080 - grpc_listen_port: 0 - -positions: - filename: /tmp/positions.yaml - -clients: - - url: http://gateway:3100/loki/api/v1/push - tenant_id: tenant1 - -scrape_configs: - - job_name: flog_scrape - docker_sd_configs: - - host: unix:///var/run/docker.sock - refresh_interval: 5s - relabel_configs: - - source_labels: ['__meta_docker_container_name'] - regex: '/(.*)' - target_label: 'container' -