Grafana LokiをAWSで動かす
Grafana LokiはデータストアにS3とDynamoDBを利用することができる。 このおかげで、AWSで動作させるのは非常にかんたんである。
設定の schema_config セクションと storage_config セクションに、それぞれDynamoDBとS3の設定をすればよいだけだ。 基本的には、権限はAssumeRoleで渡すことになると思うので、bucketnameなどを入れるだけである。
schema_config: configs: - from: 2020-02-14 store: aws object_store: s3 schema: v11 index: prefix: log- period: 168h storage_config: aws: s3: s3://ap-northeast-1/$S3 dynamodbconfig: dynamodb: dynamodb://ap-northeast-1
DynamoDBのテーブルはLokiが勝手に作っていくので、 table_manager セクションでスループットや retention や retention を過ぎたら削除するかどうかを設定してあげる。
table_manager: retention_deletes_enabled: true retention_period: 336h index_tables_provisioning: provisioned_write_throughput: 1 provisioned_read_throughput: 1 chunk_tables_provisioning: provisioned_write_throughput: 1 provisioned_read_throughput: 1
以上で動くには動く。