Menu
Open source

Run Grafana Alloy as a standalone binary

If you downloaded the standalone binary, you must run Alloy from a terminal or command window.

Refer to the run documentation for more information about the command line flags you can use when you run Alloy.

Start Alloy on Linux, macOS, or FreeBSD

To start Alloy on Linux, macOS, or FreeBSD, run the following command in a terminal window:

shell
<BINARY_PATH> run <CONFIG_PATH>

Replace the following:

  • <BINARY_PATH>: The path to the Alloy binary file.
  • <CONFIG_PATH>: The path to the Alloy configuration file.

Start Alloy on Windows

To start Alloy on Windows, run the following commands in a command prompt:

cmd
<BINARY_PATH> run <CONFIG_PATH>

Replace the following:

  • <BINARY_PATH>: The path to the Alloy binary file.
  • <CONFIG_PATH>: The path to the Alloy configuration file.

Set up Alloy as a Linux systemd service

You can set up and manage the standalone binary for Alloy as a Linux systemd service.

Note

These steps assume you have a default systemd and Alloy configuration.
  1. To create a new user called alloy run the following command in a terminal window:

    shell
    sudo useradd --no-create-home --shell /bin/false alloy
  2. Create a service file in /etc/systemd/system called alloy.service with the following contents:

    systemd
    [Unit]
    Description=Vendor-neutral programmable observability pipelines.
    Documentation=https://grafana.com/docs/alloy/
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    Restart=always
    User=alloy
    Environment=HOSTNAME=%H
    EnvironmentFile=/etc/default/alloy
    WorkingDirectory=<WORKING_DIRECTORY>
    ExecStart=<BINARY_PATH> run $CUSTOM_ARGS --storage.path=<WORKING_DIRECTORY> $CONFIG_FILE
    ExecReload=/usr/bin/env kill -HUP $MAINPID
    TimeoutStopSec=20s
    SendSIGKILL=no
    
    [Install]
    WantedBy=multi-user.target

    Replace the following:

    • <BINARY_PATH>: The path to the Alloy binary file.
    • <WORKING_DIRECTORY>: The path to a working directory, for example /var/lib/alloy.
  3. Create an environment file in /etc/default/ called alloy with the following contents:

    shell
    ## Path:
    ## Description: Grafana Alloy settings
    ## Type:        string
    ## Default:     ""
    ## ServiceRestart: alloy
    #
    # Command line options for alloy
    #
    # The configuration file holding the Grafana Alloy configuration.
    CONFIG_FILE="<CONFIG_PATH>"
    
    # User-defined arguments to pass to the run command.
    CUSTOM_ARGS=""
    
    # Restart on system upgrade. Defaults to true.
    RESTART_ON_UPGRADE=true

    Replace the following:

    • <CONFIG_PATH>: The path to the Alloy configuration file.
  4. To reload the service files, run the following command in a terminal window:

    shell
    sudo systemctl daemon-reload
  5. Use the Linux systemd commands to manage your standalone Linux installation of Alloy.