Skip to content

Commit adae6fd

Browse files
committed
docs: document log store configuration via [log_store] in config.toml
The log store guide and the environment variable reference described --log-store-* flags and GRAPH_LOG_STORE_* environment variables that do not exist; the log store is only configurable through the [log_store] section of the TOML config (#6278). Replace those examples with TOML, document every [log_store] key with its defaults, drop the nonexistent max-size/retention-days options in favour of retention_hours, and note that _logs returns a NotSupported error when no store is configured (#6637). Also update the matching startup message.
1 parent 6838f4e commit adae6fd

3 files changed

Lines changed: 68 additions & 194 deletions

File tree

‎docs/environment-variables.md‎

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -322,43 +322,14 @@ those.
322322

323323
**For complete log store documentation**, including detailed configuration, querying examples, and choosing the right backend, see the **[Log Store Guide](log-store.md)**.
324324

325-
### Quick Reference
326-
327-
**Backend selection:**
328-
- `GRAPH_LOG_STORE_BACKEND`: `disabled` (default), `elasticsearch`, `loki`, or `file`
329-
330-
**Elasticsearch:**
331-
- `GRAPH_LOG_STORE_ELASTICSEARCH_URL`: Elasticsearch endpoint URL (required)
332-
- `GRAPH_LOG_STORE_ELASTICSEARCH_USER`: Username (optional)
333-
- `GRAPH_LOG_STORE_ELASTICSEARCH_PASSWORD`: Password (optional)
334-
- `GRAPH_LOG_STORE_ELASTICSEARCH_INDEX`: Index name (default: `subgraph`)
335-
336-
**Loki:**
337-
- `GRAPH_LOG_STORE_LOKI_URL`: Loki endpoint URL (required)
338-
- `GRAPH_LOG_STORE_LOKI_TENANT_ID`: Tenant ID (optional)
339-
340-
**File-based:**
341-
- `GRAPH_LOG_STORE_FILE_DIR`: Log directory (required)
342-
- `GRAPH_LOG_STORE_FILE_MAX_SIZE`: Max file size in bytes (default: 104857600 = 100MB)
343-
- `GRAPH_LOG_STORE_FILE_RETENTION_DAYS`: Retention period (default: 30)
344-
345-
**Deprecated variables** (will be removed in future versions):
346-
- `GRAPH_ELASTICSEARCH_URL` → use `GRAPH_LOG_STORE_ELASTICSEARCH_URL`
347-
- `GRAPH_ELASTICSEARCH_USER` → use `GRAPH_LOG_STORE_ELASTICSEARCH_USER`
348-
- `GRAPH_ELASTICSEARCH_PASSWORD` → use `GRAPH_LOG_STORE_ELASTICSEARCH_PASSWORD`
349-
- `GRAPH_ELASTIC_SEARCH_INDEX` → use `GRAPH_LOG_STORE_ELASTICSEARCH_INDEX`
325+
The log store is configured in the `[log_store]` section of the TOML configuration file passed with `--config`, not through environment variables. The former `GRAPH_ELASTICSEARCH_*` / `ELASTICSEARCH_*` variables and `--elasticsearch-*` flags have been removed.
350326

351327
### Example: File-based Logs for Local Development
352328

353-
```bash
354-
mkdir -p ./graph-logs
355-
export GRAPH_LOG_STORE_BACKEND=file
356-
export GRAPH_LOG_STORE_FILE_DIR=./graph-logs
357-
358-
graph-node \
359-
--postgres-url postgresql://graph:pass@localhost/graph-node \
360-
--ethereum-rpc mainnet:https://... \
361-
--ipfs 127.0.0.1:5001
329+
```toml
330+
[log_store]
331+
backend = "file"
332+
directory = "./graph-logs"
362333
```
363334

364335
See the **[Log Store Guide](log-store.md)** for:

‎docs/log-store.md‎

Lines changed: 62 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ This guide explains how to configure subgraph indexing logs storage in graph-nod
1212
- [Loki](#loki)
1313
- [Disabled](#disabled)
1414
- [Configuration](#configuration)
15-
- [Environment Variables](#environment-variables)
16-
- [CLI Arguments](#cli-arguments)
17-
- [Configuration Precedence](#configuration-precedence)
15+
- [The `[log_store]` section](#the-log_store-section)
16+
- [Migrating from earlier configuration](#migrating-from-earlier-configuration)
1817
- [Querying Logs](#querying-logs)
1918
- [Migrating from Deprecated Configuration](#migrating-from-deprecated-configuration)
2019
- [Choosing the Right Backend](#choosing-the-right-backend)
@@ -130,22 +129,13 @@ File-based logs stream through files line-by-line with bounded memory usage.
130129

131130
#### Configuration
132131

133-
**Minimum configuration (CLI):**
134-
```bash
135-
graph-node \
136-
--postgres-url postgresql://graph:pass@localhost/graph-node \
137-
--ethereum-rpc mainnet:https://... \
138-
--ipfs 127.0.0.1:5001 \
139-
--log-store-backend file \
140-
--log-store-file-dir ./graph-logs
141-
```
132+
Add a `[log_store]` section to the `graph-node.toml` file passed with `--config`:
142133

143-
**Full configuration (environment variables):**
144-
```bash
145-
export GRAPH_LOG_STORE_BACKEND=file
146-
export GRAPH_LOG_STORE_FILE_DIR=/var/log/graph-node
147-
export GRAPH_LOG_STORE_FILE_MAX_SIZE=104857600 # 100MB
148-
export GRAPH_LOG_STORE_FILE_RETENTION_DAYS=30
134+
```toml
135+
[log_store]
136+
backend = "file"
137+
directory = "./graph-logs"
138+
retention_hours = 72 # optional; 0 (the default) keeps logs forever
149139
```
150140

151141
#### Features
@@ -160,7 +150,7 @@ export GRAPH_LOG_STORE_FILE_RETENTION_DAYS=30
160150
**Limitations:**
161151
- Not suitable for production with high log volume
162152
- No indexing (O(n) query time scales with file size)
163-
- No automatic log rotation or retention management
153+
- No log rotation; the only cleanup is the optional `retention_hours`
164154
- Single file per subgraph (no sharding)
165155

166156
#### When to Use
@@ -202,36 +192,22 @@ graph-node → Elasticsearch HTTP API → Elasticsearch cluster
202192

203193
#### Configuration
204194

205-
**Minimum configuration (CLI):**
206-
```bash
207-
graph-node \
208-
--postgres-url postgresql://graph:pass@localhost/graph-node \
209-
--ethereum-rpc mainnet:https://... \
210-
--ipfs 127.0.0.1:5001 \
211-
--log-store-backend elasticsearch \
212-
--log-store-elasticsearch-url http://localhost:9200
195+
**Minimum configuration:**
196+
```toml
197+
[log_store]
198+
backend = "elasticsearch"
199+
url = "http://localhost:9200"
213200
```
214201

215202
**Full configuration with authentication:**
216-
```bash
217-
graph-node \
218-
--postgres-url postgresql://graph:pass@localhost/graph-node \
219-
--ethereum-rpc mainnet:https://... \
220-
--ipfs 127.0.0.1:5001 \
221-
--log-store-backend elasticsearch \
222-
--log-store-elasticsearch-url https://es.example.com:9200 \
223-
--log-store-elasticsearch-user elastic \
224-
--log-store-elasticsearch-password secret \
225-
--log-store-elasticsearch-index subgraph-logs
226-
```
227-
228-
**Environment variables:**
229-
```bash
230-
export GRAPH_LOG_STORE_BACKEND=elasticsearch
231-
export GRAPH_LOG_STORE_ELASTICSEARCH_URL=http://localhost:9200
232-
export GRAPH_LOG_STORE_ELASTICSEARCH_USER=elastic
233-
export GRAPH_LOG_STORE_ELASTICSEARCH_PASSWORD=secret
234-
export GRAPH_LOG_STORE_ELASTICSEARCH_INDEX=subgraph-logs
203+
```toml
204+
[log_store]
205+
backend = "elasticsearch"
206+
url = "https://es.example.com:9200"
207+
username = "elastic"
208+
password = "secret"
209+
index = "subgraph-logs" # default: "subgraph"
210+
timeout_secs = 10 # default: 10
235211
```
236212

237213
#### Index Configuration
@@ -300,32 +276,21 @@ graph-node → Loki HTTP API → Loki
300276

301277
#### Configuration
302278

303-
**Minimum configuration (CLI):**
304-
```bash
305-
graph-node \
306-
--postgres-url postgresql://graph:pass@localhost/graph-node \
307-
--ethereum-rpc mainnet:https://... \
308-
--ipfs 127.0.0.1:5001 \
309-
--log-store-backend loki \
310-
--log-store-loki-url http://localhost:3100
279+
**Minimum configuration:**
280+
```toml
281+
[log_store]
282+
backend = "loki"
283+
url = "http://localhost:3100"
311284
```
312285

313-
**With multi-tenancy:**
314-
```bash
315-
graph-node \
316-
--postgres-url postgresql://graph:pass@localhost/graph-node \
317-
--ethereum-rpc mainnet:https://... \
318-
--ipfs 127.0.0.1:5001 \
319-
--log-store-backend loki \
320-
--log-store-loki-url http://localhost:3100 \
321-
--log-store-loki-tenant-id my-graph-node
322-
```
323-
324-
**Environment variables:**
325-
```bash
326-
export GRAPH_LOG_STORE_BACKEND=loki
327-
export GRAPH_LOG_STORE_LOKI_URL=http://localhost:3100
328-
export GRAPH_LOG_STORE_LOKI_TENANT_ID=my-graph-node
286+
**With multi-tenancy and authentication:**
287+
```toml
288+
[log_store]
289+
backend = "loki"
290+
url = "http://localhost:3100"
291+
tenant_id = "my-graph-node"
292+
username = "loki" # optional
293+
password = "secret" # optional
329294
```
330295

331296
#### Labels
@@ -364,25 +329,19 @@ When log storage is disabled (the default), subgraph logs are **still written to
364329
**Important:** "Disabled" does NOT mean logs are discarded. It means:
365330
- Logs appear in stdout/stderr (traditional behavior)
366331
- Logs are not stored in a separate queryable backend
367-
- The `_logs` GraphQL query returns empty results
332+
- The `_logs` GraphQL query returns a "not supported" error
368333

369334
This is the default behavior - logs continue to work exactly as they did before this feature was added.
370335

371336
#### Configuration
372337

373338
**Explicitly disable:**
374-
```bash
375-
export GRAPH_LOG_STORE_BACKEND=disabled
339+
```toml
340+
[log_store]
341+
backend = "disabled"
376342
```
377343

378-
**Or simply don't configure a backend** (defaults to disabled):
379-
```bash
380-
# No log store configuration = disabled
381-
graph-node \
382-
--postgres-url postgresql://graph:pass@localhost/graph-node \
383-
--ethereum-rpc mainnet:https://... \
384-
--ipfs 127.0.0.1:5001
385-
```
344+
**Or simply omit the `[log_store]` section** (defaults to disabled).
386345

387346
#### Features
388347

@@ -393,7 +352,7 @@ graph-node \
393352
- Logs still appear in stdout/stderr for debugging
394353

395354
**Limitations:**
396-
- Cannot query logs via GraphQL (`_logs` returns empty results)
355+
- Cannot query logs via GraphQL (`_logs` returns a "not supported" error)
397356
- No separation of subgraph logs from other graph-node logs in stdout
398357
- Logs mixed with system logs (harder to filter programmatically)
399358
- No structured querying or filtering capabilities
@@ -407,82 +366,27 @@ Use disabled log storage when:
407366

408367
## Configuration
409368

410-
### Environment Variables
411-
412-
Environment variables are the recommended way to configure log stores, especially in containerized deployments.
413-
414-
#### Backend Selection
415-
416-
```bash
417-
GRAPH_LOG_STORE_BACKEND=<backend>
418-
```
419-
Valid values: `disabled`, `elasticsearch`, `loki`, `file`
369+
### The `[log_store]` section
420370

421-
#### Elasticsearch
422-
423-
```bash
424-
GRAPH_LOG_STORE_ELASTICSEARCH_URL=http://localhost:9200
425-
GRAPH_LOG_STORE_ELASTICSEARCH_USER=elastic # Optional
426-
GRAPH_LOG_STORE_ELASTICSEARCH_PASSWORD=secret # Optional
427-
GRAPH_LOG_STORE_ELASTICSEARCH_INDEX=subgraph # Default: "subgraph"
428-
```
429-
430-
#### Loki
371+
The log store is configured in the `[log_store]` section of the TOML configuration file passed to `graph-node` with `--config` (see [config.md](config.md)). There are no command-line flags or environment variables for it.
431372

432-
```bash
433-
GRAPH_LOG_STORE_LOKI_URL=http://localhost:3100
434-
GRAPH_LOG_STORE_LOKI_TENANT_ID=my-tenant # Optional
435-
```
436-
437-
#### File
438-
439-
```bash
440-
GRAPH_LOG_STORE_FILE_DIR=/var/log/graph-node
441-
GRAPH_LOG_STORE_FILE_MAX_SIZE=104857600 # Default: 100MB
442-
GRAPH_LOG_STORE_FILE_RETENTION_DAYS=30 # Default: 30
443-
```
444-
445-
### CLI Arguments
446-
447-
CLI arguments provide the same functionality as environment variables and the two can be mixed together.
448-
449-
#### Backend Selection
450-
451-
```bash
452-
--log-store-backend <backend>
453-
```
454-
455-
#### Elasticsearch
456-
457-
```bash
458-
--log-store-elasticsearch-url <URL>
459-
--log-store-elasticsearch-user <USER>
460-
--log-store-elasticsearch-password <PASSWORD>
461-
--log-store-elasticsearch-index <INDEX>
462-
```
463-
464-
#### Loki
465-
466-
```bash
467-
--log-store-loki-url <URL>
468-
--log-store-loki-tenant-id <TENANT_ID>
469-
```
470-
471-
#### File
472-
473-
```bash
474-
--log-store-file-dir <DIR>
475-
--log-store-file-max-size <BYTES>
476-
--log-store-file-retention-days <DAYS>
477-
```
373+
| Key | Backends | Required | Default | Description |
374+
|-----|----------|----------|---------|-------------|
375+
| `backend` | all | yes | | `disabled` (or `none`), `elasticsearch` (or `elastic`, `es`), `loki`, `file` (or `files`) |
376+
| `url` | elasticsearch, loki | yes | | Endpoint URL |
377+
| `username` | elasticsearch, loki | no | | Basic-auth user name |
378+
| `password` | elasticsearch, loki | no | | Basic-auth password |
379+
| `index` | elasticsearch | no | `subgraph` | Index name |
380+
| `timeout_secs` | elasticsearch | no | `10` | Request timeout in seconds |
381+
| `tenant_id` | loki | no | | Loki tenant ID (`X-Scope-OrgID`) |
382+
| `directory` | file | yes | | Directory for the `.jsonl` files |
383+
| `retention_hours` | file | no | `0` | Delete entries older than this many hours; `0` keeps them forever |
478384

479-
### Configuration Precedence
385+
If the section is missing, the log store is disabled. An invalid section (for example, a missing `url`) is logged as a warning at startup, and the log store is disabled.
480386

481-
When multiple configuration methods are used:
387+
### Migrating from earlier configuration
482388

483-
1. **CLI arguments** take highest precedence
484-
2. **Environment variables** are used if no CLI args provided
485-
3. **Defaults** are used if neither is set
389+
The `--elasticsearch-url`, `--elasticsearch-user` and `--elasticsearch-password` flags and the matching `ELASTICSEARCH_*` / `GRAPH_ELASTICSEARCH_*` environment variables have been removed. Move those settings into a `[log_store]` section with `backend = "elasticsearch"`, as shown above.
486390

487391
## Querying Logs
488392

@@ -792,23 +696,23 @@ cat graph-logs/QmExample.jsonl | jq 'select(.text | contains("timeout"))'
792696
### File-based Logs
793697

794698
**Problem: Log file doesn't exist**
795-
- Check `GRAPH_LOG_STORE_FILE_DIR` is set correctly
699+
- Check `directory` in the `[log_store]` section is set correctly
796700
- Verify directory is writable by graph-node
797701

798702
**Problem: Queries are slow**
799703
- Subgraph logs file may be very large
800-
- Consider archiving old logs or implementing retention
704+
- Consider archiving old logs or setting `retention_hours`
801705
- For high-volume production use, switch to Elasticsearch or Loki
802706

803707
**Problem: Disk filling up**
804-
- Implement log rotation
708+
- Set `retention_hours` in the `[log_store]` section
805709
- Reduce log verbosity in subgraph code
806710
- Set up monitoring for disk usage
807711

808712
### Elasticsearch
809713

810714
**Problem: Cannot connect to Elasticsearch**
811-
- Verify `GRAPH_LOG_STORE_ELASTICSEARCH_URL` is correct
715+
- Verify `url` in the `[log_store]` section is correct
812716
- Check Elasticsearch is running: `curl http://localhost:9200`
813717
- Verify authentication credentials if using security features
814718
- Check network connectivity and firewall rules
@@ -828,7 +732,7 @@ cat graph-logs/QmExample.jsonl | jq 'select(.text | contains("timeout"))'
828732
### Loki
829733

830734
**Problem: Cannot connect to Loki**
831-
- Verify `GRAPH_LOG_STORE_LOKI_URL` is correct
735+
- Verify `url` in the `[log_store]` section is correct
832736
- Check Loki is running: `curl http://localhost:3100/ready`
833737
- Verify tenant ID if using multi-tenancy
834738
- Check network connectivity
@@ -847,7 +751,6 @@ cat graph-logs/QmExample.jsonl | jq 'select(.text | contains("timeout"))'
847751

848752
## Further Reading
849753

850-
- [Environment Variables Reference](environment-variables.md)
851754
- [Graph Node Configuration](config.md)
852755
- [Elasticsearch Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)
853756
- [Grafana Loki Documentation](https://grafana.com/docs/loki/latest/)

‎node/src/launcher.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ pub async fn run(
478478
None => {
479479
info!(
480480
logger,
481-
"No [log_store] section in config, log queries will return empty results"
481+
"No [log_store] section in config, log queries are not supported"
482482
);
483483
(
484484
Arc::new(graph::components::log_store::NoOpLogStore)

0 commit comments

Comments
 (0)