diff --git a/cookbooks/loki/files/etc/consul.d/service-loki.json b/cookbooks/loki/files/etc/consul.d/service-loki.json deleted file mode 100644 index 7f64580..0000000 --- a/cookbooks/loki/files/etc/consul.d/service-loki.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "service": { - "name": "loki", - "port": 3100 - } -} diff --git a/cookbooks/loki/setup.rb b/cookbooks/loki/setup.rb index 297fefb..575701f 100644 --- a/cookbooks/loki/setup.rb +++ b/cookbooks/loki/setup.rb @@ -8,10 +8,14 @@ end # Deploy `prometheus` files: -remote_file '/etc/loki/loki-config.yml' do +template '/etc/loki/loki-config.yml' do owner 'root' group 'root' mode '644' + + variables(ipaddr: node['consul']['ipaddr']) + + notifies :restart, 'service[loki]' end # Deploy `systemd` configuration for `prometheus`: @@ -27,11 +31,13 @@ service 'loki' do end # Depoy `consul` service configuration for `loki`: -remote_file '/etc/consul.d/service-loki.json' do +template '/etc/consul.d/service-loki.json' do owner 'root' group 'root' mode '644' + variables(ipaddr: node['consul']['ipaddr']) + notifies :restart, 'service[supervisor]' end diff --git a/cookbooks/loki/templates/etc/consul.d/service-loki.json.erb b/cookbooks/loki/templates/etc/consul.d/service-loki.json.erb new file mode 100644 index 0000000..d645fae --- /dev/null +++ b/cookbooks/loki/templates/etc/consul.d/service-loki.json.erb @@ -0,0 +1,12 @@ +{ + "service": { + "name": "loki", + "port": 3100, + "check":{ + "tcp": "<%= @ipaddr %>:3100", + "interval": "60s", + "timeout": "1s", + "success_before_passing": 3 + } + } +} diff --git a/cookbooks/loki/templates/etc/loki/loki-config.yml b/cookbooks/loki/templates/etc/loki/loki-config.yml new file mode 100644 index 0000000..9dc3aba --- /dev/null +++ b/cookbooks/loki/templates/etc/loki/loki-config.yml @@ -0,0 +1,45 @@ +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 + max_transfer_retries: 0 + +schema_config: + configs: + - from: 2018-04-15 + store: boltdb + object_store: filesystem + schema: v11 + index: + prefix: index_ + period: 168h + +storage_config: + boltdb: + directory: /var/opt/loki/index + + filesystem: + directory: /var/opt/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: 0s + +table_manager: + retention_deletes_enabled: false + retention_period: 0s