Skip to content

A library to embed Vector agents in Elixir applications.

Notifications You must be signed in to change notification settings

coherentpath/vector_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vector

A library to embed Vector agents inside Elixir applications.

Installation

def deps do
  [
    {:vector_agent, "~> *.*.*"}
  ]
end

Please note that curl and bash must both be available during compilation in order to download the vector agent binary.

Additionally - :vector_agent makes use of :erlexec to control vector agents. :erlexec expects a SHELL environment variable to be available - otherwise startup errors will occur. If this value is not already set - its common to set it with the value /bin/sh.

Examples

Simple logging of demo log events from a Vector agent.

config = %{
  sources: %{
    test_source: %{
      type: "demo_logs",
      format: "apache_common"
    }
  },
  sinks: %{
    test_sink: %{
      type: "console",
      inputs: ["test_source"],
      encoding: %{
        codec: "text"
      }
    }
  }
}

config = Jason.encode!(config)
file = File.cwd!() <> "/vector.json"
:ok = File.write!(file, config)

config = %Vector.Config{
  config: file,
  stdout: {Vector.Consumer.Logger, []}
}

{:ok, _} = Vector.start_link(config)

Sending events to a Vector agent that are then sent back and logged.

config = %{
  sources: %{
    test_source: %{
      type: "stdin"
    }
  },
  sinks: %{
    test_sink: %{
      type: "console",
      inputs: ["test_source"],
      encoding: %{
        codec: "text"
      }
    }
  }
}

config = Jason.encode!(config)
file = File.cwd!() <> "/vector.json"
:ok = File.write!(file, config)

config = %Vector.Config{
  config: file,
  stdout: {Vector.Consumer.Logger, []}
}

{:ok, pid} = Vector.start_link(config)
:ok = Vector.send(pid, "Hello Vector!\n")