Giter VIP home page Giter VIP logo

ruby_for_grafana_loki's Introduction

Prerequisites

What things you need to install the software and how to install them.

You need to setup Grafana, Grafana Loki for your env: 
- you can follow this video: https://www.youtube.com/watch?v=0B-yQdSXFJE
- about Grafana https://grafana.com/docs/agent/latest/flow/setup/start-agent/
- brew install grafana (install Grafana) 

Usage gem in test env:

To run gem for test(for Macbook):
after installing Grafana
- brew services start grafana (start Grafana)

  after start grafana open browser http://localhost:3000 (sighIn with login: admin, password: admin.)
  setup Grafana > Home > Connections > Data sources > Loki
  setup URL: http://localhost:3100

- brew services restart grafana-agent-flow                         // restart Grafana
- brew services stop grafana-agent-flow                            // stop Grafana

- Ctrl+C (stop Loki)                                               // stop Grafana Loki

Test gem with irb:

Go to your project folder:
- gem uninstall build rails_loki_exporter_dev                       // if you install gem before
- gem build rails_loki_exporter_dev.gemspec
- gem install rails_loki_exporter_dev-0.0.1.gem
- irb (launch ruby's interactive console)

- require 'ruby_for_grafana_loki'
- logs_type = %w(ERROR WARN FATAL INFO)                             // use custom logs type: ERROR, WARN, FATAL, INFO, DEBUG
- log_file_path = "log/#{Rails.env}.log"                            // your path to *.log
- client = RailsLokiExporterDev.client(log_folder_name, logs_type)  // create client
- result = client.send_all_logs

Usage gem in your application:

  • add gem "ruby_for_grafana_loki-0.0.6.gem" // to the Gemfile
  • bundle install

In your Rails app project

  • create file 'config/config.yml'
auth_enabled: true 
base_url: 'https://yourUrl.grafana.net'
user_name: '765***'
password: 'glc_eyJvIjoiOTk0MjI2IiwibiI6Im...wIn19'
log_file_path: "log/#{Rails.env}.log"
logs_type: '%w(INFO DEBUG)' # or use logs_type: %w(ERROR WARN FATAL INFO DEBUG)
intercept_logs: true
  • in your 'application.rb'
    config.after_initialize do
      config_file_path = File.join(Rails.root, 'config', 'config.yml')   // path to your created config.yml
      logger = RubyForGrafanaLoki.create_logger(config_file_path)
      Rails.logger = logger
    end

ruby_for_grafana_loki's People

Contributors

tennet0505 avatar

Watchers

 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.