Skip to content

davidlonjon/tide-logging-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tide Logging Server

Description

This repo will provision a Graylogw server which will capture log events/messages from the Tide services.

Dependencies

How to run locally

  • Clone the repo:
$ git clone [email protected]:davidlonjon/tide-logging-server.git
  • Create a new .env file from the .env.dist file and edit the settings:
GRAYLOG_PASSWORD_SECRET=some_password_pepper
GRAYLOG_ROOT_PASSWORD_SHA2=some_sha2_encrypted_password
GRAYLOG_WEB_ENDPOINT_URI=http://localhost:9000/api

To generate a SHA2 encrypted password you can run the following command on your local:

$ echo -n yourpassword | shasum -a 256

Launch the Graylog2 server using the docker compose command

$ docker-compose up -d

Now you should be able to access the admin console of the Graylog2 server at http://localhost:9000/api. To login use admin as the username.

To interact with the Graylog2 server to send log events to it using PHP for example, you will be able to do it using your host machine IP on port 12201 as the graylog IP address and port.

How to run on production

TBC

How to send a log event to the Graylog server using php:

You can find and how to on Jeremy Cook blog post at https://jeremycook.ca/2012/10/02/turbocharging-your-logs/.

In a nutshell, you'll need:

Code sample:

<?php

require "vendor/autoload.php";
use Monolog\Logger;
use Monolog\Handler\GelfHandler;
use Gelf\MessagePublisher;

$log = new Logger('Test');
$log->pushHandler(new GelfHandler(new MessagePublisher('IP OR DOMAIN NAME OF YOUR GRAYLOG2 SERVER')));

$log->addWarning('Test warning message');
$log->addError('Test error message');
$log->addInfo('Test info message');
$log->addDebug('Test debug message');

About

Tide Logging Server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published