API Reference

The daemon exposes an HTTP API over its unix socket. When TCP is enabled, the same API is available over TLS with optional bearer token authentication. All responses are JSON.

Endpoints

Status & Config

MethodPathDescriptionResponse
GET/api/statusDaemon status, uptime, and collector intervalsStatusResponse
GET/api/configFull daemon, alerts, and TUI configurationConfigResponse

Live Metrics

MethodPathDescriptionResponse
GET/api/metrics/cpuPer-core CPU usage percentagesCPUResponse
GET/api/metrics/memoryMemory and swap usageMemoryMetric
GET/api/metrics/diskPer-mount disk space, I/O rates, and SMART healthDiskResponse
GET/api/metrics/networkPer-interface throughput and error countersNetworkResponse
GET/api/metrics/temperatureHardware sensor temperaturesTemperatureResponse
GET/api/metrics/powerPower consumption per RAPL zonePowerResponse
GET/api/metrics/eccECC memory error countsECCResponse
GET/api/metrics/gpuGPU utilization, frequency, power, and memoryGPUResponse
GET/api/metrics/processAll processes (live in-memory snapshot)ProcessResponse
GET/api/metrics/dashboardCombined overview of all metric typesDashboardData

History

All history endpoints accept ?start= and ?end= query parameters (Unix seconds). Bucket size auto-scales: 1 min (1h range) to 6 hr (30d range).

MethodPathDescriptionResponse
GET/api/history/cpuCPU usage over timeHistoryResponse
GET/api/history/memoryMemory usage over timeHistoryResponse
GET/api/history/diskDisk space and I/O over timeHistoryResponse
GET/api/history/networkNetwork throughput over timeHistoryResponse
GET/api/history/temperatureTemperature over timeHistoryResponse
GET/api/history/powerPower consumption over timeHistoryResponse
GET/api/history/gpuGPU metrics over timeHistoryResponse
GET/api/history/processTop processes by CPU over timeHistoryResponse

Alerts

MethodPathDescriptionResponse
GET/api/alertsList fired alertsAlertsResponse
POST/api/alerts/{id}/ackAcknowledge a fired alertGenericResponse
GET/api/alert-rulesList all alert rulesAlertRulesResponse
POST/api/alert-rulesCreate a new alert ruleGenericResponse
DELETE/api/alert-rules/{id}Delete an alert ruleGenericResponse
PUT/api/alert-rules/{id}/toggleToggle a rule enabled/disabledGenericResponse
POST/api/test-notificationsSend a test alert to all notification channelsNotifyTestResponse

Query & Export

MethodPathDescriptionResponse
POST/api/queryExecute a read-only SQL queryQueryResponse
POST/api/exportExport query results to a file (CSV, Parquet, or JSON)ExportResponse

Data Management

MethodPathDescriptionResponse
POST/api/compactTrigger database compactionGenericResponse
POST/api/snapshotCreate a standalone database snapshotSnapshotResponse
POST/api/archiveTrigger Parquet archival of old dataGenericResponse
POST/api/unarchiveReload Parquet data into the databaseGenericResponse
GET/api/archive/statusArchive state and directory statisticsArchiveStatusResponse

Preferences

MethodPathDescriptionResponse
GET/api/preferencesGet all saved preferencesPreferencesResponse
POST/api/preferencesSet a preference key/value pairGenericResponse

Examples

get daemon status
curl --unix-socket /run/bewitch/bewitch.sock \
  http://localhost/api/status
get CPU metrics
curl --unix-socket /run/bewitch/bewitch.sock \
  http://localhost/api/metrics/cpu
get history with time range
curl --unix-socket /run/bewitch/bewitch.sock \
  "http://localhost/api/history/cpu?start=$(date -d '1 hour ago' +%s)&end=$(date +%s)"
create alert rule
curl --unix-socket /run/bewitch/bewitch.sock \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "high-cpu",
    "type": "threshold",
    "severity": "warning",
    "metric": "cpu.aggregate",
    "operator": ">",
    "value": 90,
    "duration": "5m"
  }' \
  http://localhost/api/alert-rules
execute SQL query
curl --unix-socket /run/bewitch/bewitch.sock \
  -H 'Content-Type: application/json' \
  -d '{"sql": "SELECT COUNT(*) as n FROM cpu_metrics"}' \
  http://localhost/api/query
remote access (TCP + TLS + auth)
curl -k -H "Authorization: Bearer my-secret-token" \
  https://myserver:9119/api/status

Response Types

Timestamps are int64 Unix nanoseconds. Arrays are always wrapped in objects. Errors return {"error": "message"}.

StatusResponse

FieldType
statusstring
uptime_secnumber
default_intervalstring
collector_intervalsmap<string, string>optional

ConfigResponse

FieldType
daemonDaemonConfigResponse
alertsAlertsConfigResponse
tuiTUIConfigResponse

DaemonConfigResponse

FieldType
socketstring
db_pathstring
default_intervalstring

AlertsConfigResponse

FieldType
evaluation_intervalstring
emailEmailDestResponse[]optional
commandsCommandDestResponse[]optional

EmailDestResponse

FieldType
use_mail_cmdbooleanoptional
smtp_hoststringoptional
smtp_portnumberoptional
fromstringoptional
tostring[]

CommandDestResponse

FieldType
cmdstring

TUIConfigResponse

FieldType
refresh_intervalstring

CPUResponse

FieldType
coresCPUCoreMetric[]

CPUCoreMetric

FieldType
corenumber
user_pctnumber
system_pctnumber
idle_pctnumber
iowait_pctnumber

MemoryMetric

FieldType
total_bytesnumber
used_bytesnumber
available_bytesnumber
buffers_bytesnumber
cached_bytesnumber
swap_total_bytesnumber
swap_used_bytesnumber

DiskResponse

FieldType
disksDiskMetric[]

DiskMetric

FieldType
mountstring
devicestring
transportstringoptional
total_bytesnumber
used_bytesnumber
free_bytesnumber
read_bytes_secnumber
write_bytes_secnumber
read_iopsnumber
write_iopsnumber
smart_availableboolean
smart_healthybooleanoptional
smart_temperaturenumberoptional
smart_power_on_hoursnumberoptional
smart_power_cyclesnumberoptional
smart_read_sectorsnumberoptional
smart_written_sectorsnumberoptional
smart_reallocatednumberoptional
smart_pendingnumberoptional
smart_uncorrectablenumberoptional
smart_read_error_ratenumberoptional
smart_available_sparenumberoptional
smart_percent_usednumberoptional

NetworkResponse

FieldType
interfacesNetworkMetric[]

NetworkMetric

FieldType
interfacestring
rx_bytes_secnumber
tx_bytes_secnumber
rx_packets_secnumber
tx_packets_secnumber
rx_errorsnumber
tx_errorsnumber

TemperatureResponse

FieldType
sensorsTemperatureMetric[]

TemperatureMetric

FieldType
sensorstring
temp_celsiusnumber

PowerResponse

FieldType
zonesPowerMetric[]

PowerMetric

FieldType
zonestring
wattsnumber

ECCResponse

FieldType
eccECCMetric

ECCMetric

FieldType
correctednumber
uncorrectednumber

GPUResponse

FieldType
gpusGPUMetric[]
hintsstring[]optional

GPUMetric

FieldType
namestring
indexnumber
vendorstring
utilization_pctnumber
memory_used_bytesnumber
memory_total_bytesnumber
temp_celsiusnumber
power_wattsnumber
frequency_mhznumber
frequency_max_mhznumber
throttle_pctnumber

ProcessResponse

FieldType
processesProcessMetric[]
total_procsnumber
running_procsnumber
active_procsnumber
total_cpu_pctnumber
total_rss_bytesnumber
enriched_countnumber

ProcessMetric

FieldType
pidnumber
ppidnumber
namestring
cmdlinestring
statestring
uidnumber
cpu_user_pctnumber
cpu_system_pctnumber
rss_bytesnumber
vss_bytesnumber
shared_bytesnumber
swap_bytesnumber
num_fdsnumber
num_threadsnumber
start_time_nsnumber
enrichedboolean

DashboardData

FieldType
cpuCPUCoreMetric[]
memoryMemoryMetricoptional
disksDiskMetric[]
networkNetworkMetric[]
temperatureTemperatureMetric[]
powerPowerMetric[]
gpuGPUMetric[]optional
processesProcessResponseoptional

HistoryResponse

FieldType
seriesTimeSeries[]

TimeSeries

FieldType
labelstring
pointsTimeSeriesPoint[]

TimeSeriesPoint

FieldType
timestamp_nsnumber
valuenumber

AlertsResponse

FieldType
alertsAlertMetric[]

AlertMetric

FieldType
idnumber
timestampstring
rule_namestring
severitystring
messagestring
acknowledgedboolean

GenericResponse

FieldType
statusstringoptional
errorstringoptional

AlertRulesResponse

FieldType
rulesAlertRuleMetric[]

AlertRuleMetric

FieldType
idnumber
namestring
typestring
severitystring
enabledboolean
metricstringoptional
operatorstringoptional
valuenumberoptional
durationstringoptional
mountstringoptional
interface_namestringoptional
sensorstringoptional
predict_hoursnumberoptional
threshold_pctnumberoptional
delta_thresholdnumberoptional
min_countnumberoptional
process_namestringoptional
process_patternstringoptional
min_instancesnumberoptional
restart_thresholdnumberoptional
restart_windowstringoptional
check_durationstringoptional

NotifyTestResponse

FieldType
resultsNotifyResult[]

NotifyResult

FieldType
methodstring
deststring
status_codenumberoptional
latency_nsnumber
errorstringoptional
bodystringoptional

QueryResponse

FieldType
columnsstring[]optional
rowsany[][]optional
errorstringoptional

QueryRequest

FieldType
sqlstring

ExportResponse

FieldType
row_countnumber
pathstring
errorstringoptional

ExportRequest

FieldType
sqlstring
pathstring
formatstringoptional

SnapshotResponse

FieldType
pathstring
size_bytesnumber
errorstringoptional

SnapshotRequest

FieldType
pathstring
with_system_tablesbooleanoptional

ArchiveStatusResponse

FieldType
tablesArchiveStatusItem[]
total_filesnumber
total_bytesnumber

ArchiveStatusItem

FieldType
table_namestring
last_archived_tsstring

PreferencesResponse

FieldType
itemsmap<string, string>

PreferenceRequest

FieldType
keystring
valuestring

ETag Caching

Live metric endpoints include ETag headers. SendIf-None-Match to receive 304 Not Modified when data hasn't changed.