Botmotive

Send logs from your own server to Botmotive

This page helps you send nginx, Apache or Caddy access logs from your own server to Botmotive, with a log shipper that needs root access and Python 3.

You add a log format that carries the headers Botmotive needs, then run botmotive-ship. It is one Python 3 file with no dependencies. It tails the log and sends a gzipped batch every minute, or every 5,000 lines. Every file here can be downloaded from https://botmotive.io/ship/<file>.

Shipping logs doesn't block anything. To enforce fixes, use the snippets the dashboard gives you, or a guard in your app.

What you need first

  • A Botmotive account and a site. See Getting started.
  • Your site ID, such as my-shop. It is shown in Settings next to Site ID.
  • Your ingest token, which starts with bm_.
  • A Linux server with systemd, Python 3 and root access.

A new site starts with no token. Its install page makes one for you: open your site, choose Your own server (or click Connection steps in Settings), and click Make a token. The token is shown only once, and Botmotive keeps only a hash of it. You can also make one in Settings:

  1. Open your site in the dashboard and click Settings.
  2. Under Tokens, click New token. Name it after what will use it, such as Web server, and click Make token.
  3. Click Copy and store the token somewhere safe.

Other tokens keep working. If an old token may have leaked, click Revoke next to it.

Install

1. Add the log format

Each format writes a second log. Your existing logs are untouched.

nginx. Save nginx.conf inside the http {} block, for example as a file in conf.d, then reload:

sudo curl -fsSLo /etc/nginx/conf.d/botmotive.conf https://botmotive.io/ship/nginx.conf
sudo nginx -t && sudo systemctl reload nginx

It writes /var/log/nginx/botmotive.log. If a server block has its own access_log line, it doesn't inherit this one. Add access_log /var/log/nginx/botmotive.log botmotive; to that block too.

Apache 2.4. On Debian and Ubuntu:

sudo curl -fsSLo /etc/apache2/conf-available/botmotive.conf https://botmotive.io/ship/apache.conf
sudo a2enconf botmotive
sudo apachectl configtest && sudo systemctl reload apache2

It writes /var/log/apache2/botmotive.log.

Caddy. Caddy's JSON access log already has the headers. Copy the log botmotive { ... } block from caddy.conf into each site block in your Caddyfile, then run caddy reload. It writes /var/log/caddy/botmotive.log.

A plain combined-format log also works, with fewer signals. Point the shipper at it in step 3.

2. Install the shipper

sudo curl -fsSLo /usr/local/bin/botmotive-ship https://botmotive.io/ship/botmotive-ship.py
sudo curl -fsSLo /etc/systemd/system/botmotive-ship.service https://botmotive.io/ship/botmotive-ship.service
sudo install -m 600 /dev/null /etc/botmotive.env

3. Add your settings

Open /etc/botmotive.env as root and add three lines:

BOTMOTIVE_SITE=my-shop
BOTMOTIVE_TOKEN=bm_...
BOTMOTIVE_LOG=/var/log/nginx/botmotive.log

For Apache, use BOTMOTIVE_LOG=/var/log/apache2/botmotive.log. For Caddy, use BOTMOTIVE_LOG=/var/log/caddy/botmotive.log.

Caddy only. Its log belongs to the caddy group. Run sudo systemctl edit botmotive-ship and add:

[Service]
SupplementaryGroups=caddy

4. Start it

sudo systemctl daemon-reload
sudo systemctl enable --now botmotive-ship

5. Set your domain

In Botmotive, open Settings. Fill in Domain under Your site's address, then click Save. Botmotive then reads your robots.txt and sitemap once a day.

Settings that matter

Variable Default
BOTMOTIVE_SITE, BOTMOTIVE_TOKEN none, both required
BOTMOTIVE_LOG /var/log/nginx/botmotive.log
BOTMOTIVE_API https://api.botmotive.io
BOTMOTIVE_STATE /var/lib/botmotive/ship.state

Client IP. Behind a load balancer or CDN, the connecting address is private. Botmotive then takes the rightmost public X-Forwarded-For entry. For Apache, you can turn on mod_remoteip with RemoteIPHeader X-Forwarded-For instead. For Caddy, list your proxies under trusted_proxies in the global options, as shown in caddy.conf.

Reading the log. The systemd unit runs as a temporary user in the adm group. nginx and Apache logs on Debian and Ubuntu are readable by adm.

If your logs belong to a different group, check with ls -l on the log file. Then run sudo systemctl edit botmotive-ship and add that group:

[Service]
SupplementaryGroups=<group>

Save, then run sudo systemctl restart botmotive-ship.

Restarts and rotation. The shipper saves its place only after Botmotive accepts a batch. It follows log rotation, by rename or copytruncate. After a network outage, it retries with backoff of up to 5 minutes.

Vector or Fluent Bit. If you already run one of these, use vector.toml or fluent-bit.conf instead of the shipper. Change the log path in it, then run it with BOTMOTIVE_SITE and BOTMOTIVE_TOKEN set. Both post to https://api.botmotive.io/v1/ingest/<site>?source=nginx.

Enforcing fixes. Each fix in the dashboard has a Rule for your CDN or server section. Path denials include nginx and Apache .htaccess snippets. Or add a guard to your app: Next.js and Node, Django or Laravel.

robots.txt and /license.xml. In Settings, Botmotive shows Your AI bot rules and Your RSL license when they're on. Paste the rules at the end of your robots.txt. Save the license as license.xml at your site root.

Check it worked

  1. Watch the shipper's log:

    journalctl -u botmotive-ship -f
    

    Within a minute of traffic you should see sent 120 lines: 118 accepted, 2 skipped. A few skipped lines are normal.

  2. Open your site in the dashboard and click the 15m tab.

    Once requests arrive, the dashboard says Receiving data with a count of requests so far. Results follow 15 to 30 minutes after the first request, and the dashboard opens on the tab that has them.

botmotive-ship --once sends what's in the log and exits. It shares the service's saved position, so run it only while the service is stopped.

Updating and removing

  • Update. Download botmotive-ship.py again to /usr/local/bin/botmotive-ship, then sudo systemctl restart botmotive-ship.
  • New token. Change BOTMOTIVE_TOKEN in /etc/botmotive.env, then restart. The shipper keeps retrying with the old token until you do, so no lines are lost.
  • Remove. Run sudo systemctl disable --now botmotive-ship. Delete the unit file, /usr/local/bin/botmotive-ship and /etc/botmotive.env. Remove the log format and reload your web server.

If something goes wrong

  • send failed, retrying ... HTTP 401 (check BOTMOTIVE_SITE and BOTMOTIVE_TOKEN). The site ID or token is wrong, or the token was replaced.
  • waiting for ... to appear. The log file doesn't exist yet. Check BOTMOTIVE_LOG and that your web server writes the file.
  • Nothing is sent. Check the file grows when you load a page. For nginx, check the access_log note in step 1.
  • botmotive-ship: set BOTMOTIVE_SITE and BOTMOTIVE_TOKEN. The env file is missing a value.

For more, see Troubleshooting.

All guides