Getting Started Guide

This guide will help you go from logs to Llama Logs in no time.

As an example we will walk through adding Llama Logs to a simple NodeJS server.

Step 1: Create Your Free Llama Logs Account

Head to The Sign Up Page to create your account.

Step 2: Find Graph Details in Llama Logs

Once you sign up or sign in, your homepage will show the "myFirstGraph" graph.

This graph is auto created for all new users.

Your homepage will also show your default account key.

These values together will be used to identify your graph in your logs.

Step 3: Import the Llama Logs Client into Your Codebase

There are open source Llama Logs Clients available for several languages.

These clients take care of bundling your Llama Logs and sending them to the central Llama Logs server.

Find the client you need from the list below

  1. NodeJS: GitHub Repo
  2. Python: GitHub Repo
  3. Elixir: GitHub Repo
  4. Go: GitHub Repo

For the Node example it is as simple as running the following code in your project directory.

npm install llamalogs

Step 4: Add the Llama Logs Calls into Your Codebase

Initialization

The first step to having logs appear live in your Llama Log graph is to initialize the client.

Examples for how to initialize the client in each language can be found in the client readme files.

The required account key will be shown on your homepage.


The initialization call for NodeJS is shown below

  let { LlamaLogs } = require('llamalogs');

  LlamaLogs.init({
    accountKey: 'My_Account_Key',
    graphName: 'myFirstGraph'
  });
                        

In general the initialization function will set the default account key and graph to be used for all future Llama Logs calls. It will also start a background thread that will automatically send the accumulated Llama Logs into the central server at regular intervals. The init function is idempotent, so don't worry if you accidentally call it more than once.


Logging

Llama Logs graphs are auto generated by the logging statements that are triggered in your code.

In a log statement, you can specify several attributes:


  1. The sending and receiving components
  2. The log text to be attached to the event
  3. Dynamic determination if the event is an error

For this NodeJS example we will add statements to a basic server that log each time a user loads the site, and each time the users info is sent to an imaginary database. Also we will inject some fictional errors so that they show up on our graph.

const express = require('express')
const app = express()
const port = 3000
const saveToMockDB = (input) => input - 0.5

let { LlamaLogs } = require('llamalogs');

LlamaLogs.init({
    accountKey: 'My_Account_Key',
    graphName: 'myFirstGraph'
});

app.get('/', (req, res) => {
    LlamaLogs.log({ sender: 'User', receiver: 'App Server', message: 'Incoming Request from User' })

    // mocking a db call that is erroring 50% of the time!!!
    const mockInput = Math.random()
    const dbResult = saveToMockDB(mockInput)
    const isDbError = dbResult < 0

    LlamaLogs.log({ sender: 'App Server', receiver: 'DB', message: `value: ${mockInput}`, isError: isDbError })

    res.send('Hello World!')

    LlamaLogs.log({ sender: 'App Server', receiver: 'User'})
})

app.listen(port, () => console.log(`App started on http://localhost:${port}`))

                        

Step 5: Run Your Code

Your code must be run in order to send events to Llama Logs.

It can be run on a cloud server or locally, which makes Llama Logs great for debugging both production and dev issues.


If you have been following along with the Node example, you can run the NodeJS file and then visit http://localhost:3000 several times in your browser to trigger events.


LlamaLogs will quickly send in your first batch of logs into the central server. After the first communication it will continue to send in log data about every minute.

If you do not want to wait, Llamalogs.forceSend() can be used to send all accumulated logs into the server. However, each account has rate limits which you will hit very quickly if every log is sent in individually using forceSend().

Step 6: View the Logs Appear in Your Live Graph

Now click the "View Graph" link next to "myFirstGraph" on your homepage.

After about 1 minute, the client will send the logs into the server and you will see the components and events appear automatically in your graph.


Below is an example of what the graph looks like for the NodeJS example.

All of the component icons, logs, and relationship lines are auto generated by the Llama Logs system.

Also take notice of the red log showing errors occurring between the App Server and DB.



By clicking the "Pause Graph" button and hovering the error, you will be shown a sample of your custom log statements attached to the error.

Step 7: Explore Llama Logs Examples

This getting started guide only showcased the bare minumum of Llama Logs features.

Continue exploring all the powerful features and use cases of Llama Logs in the documentation.


Demo - 2 click demo to have you playing with a live graph in seconds.

Example Use Cases - Sample architectures showing how Llama Logs can bring visibility to your system.

User Guide - Guide for features of the web interface.

Client Docs - Detailed docs for the client libraries.