Calmcode - vector: first demo

Setting up a Vector config file.

1 2 3 4 5 6

Let's now start our FastAPI app.

import json
import datetime as dt
from fastapi import FastAPI

app = FastAPI()

def log():
    print(json.dumps({'dt': str(, "info": "this workz!"}))
    return {"alive": "yes"}

But now we'll run it with vector around!

python -m uvicorn app:app | vector --config vector.toml

Here's the vector file that we use in the video.

type = "stdin"

inputs = ["in"]
type = "file"
compression = "none"
encoding.codec = "ndjson"
path = "/tmp/vector-%Y-%m-%d.log"

inputs = ["in"]
type = "console"
encoding.codec = "text"

This file represents a graph of sources and sinks. Sources represent sources of events while sinks represent endpoints. In this config file we define three nodes; one for the stdin source, one for the stdout sink and another one for the logfile. With such a config Vector can route the logs without any extra effort in our webapp.