github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/clients/cmd/fluentd/README.md (about)

     1  # Fluentd output plugin
     2  
     3  [Fluentd](https://fluentd.org/) is a data collector for unified logging layer, it can be configured with the Loki output plugin, provided in this folder, to ship logs to Loki.
     4  
     5  See [docs/client/fluentd/README.md](../../docs/sources/clients/fluentd/_index.md) for detailed information.
     6  
     7  ## Development
     8  
     9  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
    10  
    11  To install this gem onto your local machine, run `ruby -S bundle exec rake install`. To release a new version, update the version number in `fluent-plugin-grafana-loki.gemspec`, and then run `ruby -S bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
    12  
    13  To create the gem: `ruby -S gem build fluent-plugin-grafana-loki.gemspec`
    14  
    15  Useful additions:
    16  
    17  ```bash
    18  ruby -S gem install rubocop
    19  ```
    20  
    21  ## Testing
    22  
    23  Start Loki using:
    24  
    25  ```bash
    26  docker run -it -p 3100:3100 grafana/loki:latest
    27  ```
    28  
    29  Verify that Loki accept and stores logs:
    30  
    31  ```bash
    32  curl -H "Content-Type: application/json" -XPOST -s "http://localhost:3100/loki/api/v1/push" --data-raw "{\"streams\": [{\"stream\": {\"job\": \"test\"}, \"values\": [[\"$(date +%s)000000000\", \"fizzbuzz\"]]}]}"
    33  curl "http://localhost:3100/loki/api/v1/query_range" --data-urlencode 'query={job="test"}' --data-urlencode 'step=300' | jq .data.result
    34  ```
    35  
    36  The expected output is:
    37  
    38  ```json
    39  [
    40    {
    41      "stream": {
    42        "job": "test"
    43      },
    44      "values": [
    45        [
    46          "1588337198000000000",
    47          "fizzbuzz"
    48        ]
    49      ]
    50    }
    51  ]
    52  ```
    53  
    54  Start and send test logs with Fluentd using:
    55  
    56  ```bash
    57  LOKI_URL=http://{{ IP }}:3100 make fluentd-test
    58  ```
    59  
    60  Verify that syslogs are being feeded into Loki:
    61  
    62  ```bash
    63  curl "http://localhost:3100/loki/api/v1/query_range" --data-urlencode 'query={job="fluentd"}' --data-urlencode 'step=300' | jq .data.result
    64  ```
    65  
    66  The expected output is:
    67  
    68  ```json
    69  [
    70    {
    71      "stream": {
    72        "job": "fluentd"
    73      },
    74      "values": [
    75        [
    76          "1588336950379591919",
    77          "log=\"May  1 14:42:30 ibuprofen avahi-daemon[859]: New relevant interface vethb503225.IPv6 for mDNS.\""
    78        ],
    79        ...
    80      ]
    81    }
    82  ]
    83  ```
    84  
    85  ## Copyright
    86  
    87  * Copyright(c) 2018- Grafana Labs
    88  * License
    89    * Apache License, Version 2.0