Git Product home page Git Product logo

nginx-log-generator's Introduction

Nginx Log Generator

A tiny Go utility to generate a large amount realistic-looking Nginx logs quickly. It was written to aid in testing logging pipelines and other such tools, and demoing them in Kubernetes.

Most of the heavy lifting is done by the amazing gofakeit library, with some extra work to skew the results towards typical values.

Usage

The most important step is to set the desired rate in the RATE environment variable. The simplest way to do this is the following:

$ # Will generate 10 entries per second
$ RATE=10 ./nginx-log-generator

The reason this is an environment variable is so it's easier to run via Docker as well:

$ docker pull kscarlett/nginx-log-generator
$ docker run -e "RATE=10" kscarlett/nginx-log-generator

Configuration

The following environment variables can be set to modify the output.

Name Default Notes
RATE 1 Logs to output per second.
IPV4_PERCENT 100 Percentage of IP addresses that will be IPv4. Change to 0 to only get IPv6.
STATUS_OK_PERCENT 80 Roughly the percentage of 200 status codes. The rest will be randomised and may contain 200 as well.
PATH_MIN 1 Minimum elements to put in the request path.
PATH_MAX 5 Maximum elements to put in the request path.
GET_PERCENT 60 Percentage of requests that will be GET requests. If the total adds up to less than 100%, the rest will be made up of random HTTP methods.
POST_PERCENT 30 Percentage of requests that will be POST requests. If the total adds up to less than 100%, the rest will be made up of random HTTP methods.
PUT_PERCENT 0 Percentage of requests that will be PUT requests. If the total adds up to less than 100%, the rest will be made up of random HTTP methods.
PATCH_PERCENT 0 Percentage of requests that will be PATCH requests. If the total adds up to less than 100%, the rest will be made up of random HTTP methods.
DELETE_PERCENT 0 Percentage of requests that will be DELETE requests. If the total adds up to less than 100%, the rest will be made up of random HTTP methods.

Note

This is a tool I made in no time at all, because I needed a tool that did exactly this right that second. The code quality isn't optimal and it can probably be optimised. I will be coming back to it at some other time.

License

This tool is released under the MIT License.

nginx-log-generator's People

Contributors

kscarlett avatar

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.