Giter Site home page Giter Site logo

cloudfront2loki's Introduction

cloudfront2loki

Description

This is for consuming Cloudfront logs from s3 and pushing them to Loki. It parses the Cloudfront logs for timestamps and fields to use for Loki labels as well as convert the logs to json.

Usage

This assumes you've either set AWS key ENVs or you're using roles. You'll need to generate a configfile that looks like the following.

region: "us-east-1"
bucket: "YOURBUCKETNAME"
prefix: "SUBDIRECTORY/CLOUDFRONT_DISTRO_ID"
concurrency: 2
lokihost: "LOKI-HOSTNAME:3100"
lokilabels: "{source=\"cloudfront\",job=\"cloudfront2loki\"}"
lokibatchsize: 10
lokibatchwaitseconds: 5
lokiloglevel: DISABLE
startafterfile: "SUBDIRECTORY/CLOUDFRONT_FILE_YOU_WANT_TO_START_FROM"
loopsleepseconds: 60
loglevel: info
# ignorelokilatestlog: true

Behavior

This will start up and query Loki using the labels from the config. It will find the last log entry in Loki, get the filename from that and start downloading from s3 all the files from that hour onward. You can change this behavior with the ignorelokilatestlog option and it will instead just start with the startafterfile alphanumerically (NOT BY DATE). It does avoid re-importing logs into Loki it's imported before by checking every time it sees a new filename if Loki already has any entries for that filename and skips the file if it does. This means if it stops in the middle of importing a file, you'll need to remove all of those entries from Loki to get it to re-import the file.

Docker

TODO

License and Author

Copyright 2020, Searchspring, LLC.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.