From d71825a506fac8630f0e2325d22079ce7793a58c Mon Sep 17 00:00:00 2001 From: Idris Dev Date: Mon, 10 Oct 2022 18:24:44 +1100 Subject: [PATCH] feat (logger/Server): add loki documentation section I also briefly added headers --- docs/ox_lib/Logger/Server.md | 60 +++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/docs/ox_lib/Logger/Server.md b/docs/ox_lib/Logger/Server.md index 61ab5907..13d153f2 100644 --- a/docs/ox_lib/Logger/Server.md +++ b/docs/ox_lib/Logger/Server.md @@ -1,4 +1,4 @@ -Submit logs to Datadog. +## Submit logs to Datadog Register an account with [datadog](https://www.datadoghq.com/). Once registered you need to create an [API key](https://app.datadoghq.com/organization-settings/api-keys). Modify your `server.cfg` with the newly generated API key and [intake server](https://docs.datadoghq.com/api/latest/logs/#send-logs). @@ -32,3 +32,61 @@ lib.logger(-1, 'CreateVehicle', json.encode(vehicle)) ![image](https://user-images.githubusercontent.com/65407488/165902870-4c938da7-a068-4d19-af5b-20402c325e87.png) ![image](https://user-images.githubusercontent.com/65407488/165902834-702a738d-9ae2-4725-ad85-8b8835115f7d.png) + +## Submit logs to Grafana Loki + +Loki is a horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus. It is designed to be very cost effective and easy to operate. It does not index the contents of the logs, but rather a set of labels for each log stream. + +You can take two routes with Grafana Loki: + +[Grafana Cloud](https://grafana.com/) + +- Has free tier with some restrictions +- Easy to manage +- Easier to setup +- Mostly Managed by Grafana + +Self-Host [Grafana Stack](https://grafana.com/get/?plcmt=top-nav&cta=downloads&tab=self-managed) + +- No imposed restrictions +- Requires own server +- Complicated to setup +- Self-Managed + +### Grafana Cloud Setup (Easy) + +Once registered with Grafana Cloud, head to [My Account](https://grafana.com/auth/sign-in/?plcmt=top-nav&cta=myaccount) click your named stack (should be under Grafana Cloud section) and then click Details on the Loki section. Click Generate Now where it says password. Save the key for later. Save your user and url also, you don't need the `https://` + +### Grafana Self-Hosted Setup (Experience Required) + +To setup a grafana instance you'll require docker, and knowledge on containers or kubernetes. Please find a guide to setup a grafana stack (min requirement grafana and grafana loki) and follow that. Once done, setup authentication and use the username and password securing your endpoint. + +[*] Please note: By default self-hosted loki instances do not come with authentication and will require an authentication layer on top such as `nginx basic_auth`. + +#### Setting up Server Config + +Open your server.cfg and if you have previously used datadog logging, change the `ox:logger` tag to be loki if not add the following tags to your cfg. + +``` +set ox:logger "loki" +set loki:user "" +set loki:key "" +set loki:endpoint "" +``` + +Here is an example + +``` +set ox:logger "loki" +set loki:user "1337" +set loki:key "alongcomplicatedsecurepassword" +set loki:endpoint "logs.mywebsite.com" +``` + +#### Inserting data + +The data can be inserted into Loki the same way as datadog so you can follow the log format from the above datadog section. + +#### Browsing Data + +If you're unfamiliar with how to use Loki please follow an online guide or a youtube video. You can get quite indepth with what you can do, you can even track metrics and economic health all from logs.