Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Metrics, metrics endpoint, and showing cool data #2024

Merged
merged 4 commits into from
May 27, 2025

Conversation

perfectra1n
Copy link
Member

Closes TriliumNext/Trilium#4971

I'm not sure if (or how) we would like to expose these values to the client? What do you think would be the best way? Of course there are several reasons why we would like to have them available, I'm not sure of the best way to show them in the client...

Copy link

github-actions bot commented May 26, 2025

Folder/File Previous size New size Difference
/upload/TriliumNextNotes-Server-2024-merge-linux-x64.tar.xz 66.72MB +66.72MB (+100.00%)
TOTAL +66.72MB

@perfectra1n
Copy link
Member Author

perfectra1n commented May 26, 2025

This is what the output looks like.

For Prometheus:

(v23.11.0) [root on DESKTOP-8EMKV7Q] ~/repos/TriliumNext/Notes on feat/metrics-endpoint
 Γ¥»  curl 'http://localhost:8080/etapi/metrics' -H "Authorization: lQsQRo00SfO4_G8nxsbhOWuWF3hzxcmQB8rviQz/Xg7cnEiv4Yu6blR4="
# HELP trilium_info Trilium instance information
# TYPE trilium_info gauge
trilium_info{version="0.94.0",db_version="231",node_version="v23.11.0",sync_version="35",build_date="2025-04-10T18:06:20Z",build_revision="3df666b03e55a7719958a20cbd9e14601d7da580"} 1 1748291013

# HELP trilium_notes_total Total number of notes including deleted
# TYPE trilium_notes_total gauge
trilium_notes_total 427 1748291013

# HELP trilium_notes_deleted Number of deleted notes
# TYPE trilium_notes_deleted gauge
trilium_notes_deleted 0 1748291013

# HELP trilium_notes_active Number of active notes
# TYPE trilium_notes_active gauge
trilium_notes_active 427 1748291013

# HELP trilium_notes_protected Number of protected notes
# TYPE trilium_notes_protected gauge
trilium_notes_protected 0 1748291013

# HELP trilium_attachments_total Total number of attachments including deleted
# TYPE trilium_attachments_total gauge
trilium_attachments_total 18 1748291013

# HELP trilium_attachments_deleted Number of deleted attachments
# TYPE trilium_attachments_deleted gauge
trilium_attachments_deleted 0 1748291013

# HELP trilium_attachments_active Number of active attachments
# TYPE trilium_attachments_active gauge
trilium_attachments_active 18 1748291013

# HELP trilium_revisions_total Total number of note revisions
# TYPE trilium_revisions_total gauge
trilium_revisions_total 1 1748291013

# HELP trilium_branches_total Number of active branches
# TYPE trilium_branches_total gauge
trilium_branches_total 441 1748291013

# HELP trilium_attributes_total Number of active attributes
# TYPE trilium_attributes_total gauge
trilium_attributes_total 739 1748291013

# HELP trilium_blobs_total Total number of blob records
# TYPE trilium_blobs_total gauge
trilium_blobs_total 147 1748291013

# HELP trilium_etapi_tokens_total Number of active ETAPI tokens
# TYPE trilium_etapi_tokens_total gauge
trilium_etapi_tokens_total 1 1748291013

# HELP trilium_recent_notes_total Number of recent notes tracked
# TYPE trilium_recent_notes_total gauge
trilium_recent_notes_total 11 1748291013

# HELP trilium_embeddings_total Number of note embeddings
# TYPE trilium_embeddings_total gauge
trilium_embeddings_total 0 1748291013

# HELP trilium_embedding_providers_total Number of embedding providers
# TYPE trilium_embedding_providers_total gauge
trilium_embedding_providers_total 1 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="doc"} 179 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="text"} 115 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="code"} 25 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="launcher"} 25 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="book"} 21 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="contentWidget"} 16 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="mermaid"} 13 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="image"} 12 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="render"} 7 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="file"} 5 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="webView"} 5 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="canvas"} 1 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="geoMap"} 1 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="mindMap"} 1 1748291013

# HELP trilium_notes_by_type Number of notes by type
# TYPE trilium_notes_by_type gauge
trilium_notes_by_type{type="noteMap"} 1 1748291013

# HELP trilium_attachments_by_type Number of attachments by MIME type
# TYPE trilium_attachments_by_type gauge
trilium_attachments_by_type{mime_type="image/svg+xml"} 16 1748291013

# HELP trilium_attachments_by_type Number of attachments by MIME type
# TYPE trilium_attachments_by_type gauge
trilium_attachments_by_type{mime_type="image/jpg"} 2 1748291013

# HELP trilium_database_size_bytes Database size in bytes
# TYPE trilium_database_size_bytes gauge
trilium_database_size_bytes 2514944 1748291013

# HELP trilium_oldest_note_timestamp Timestamp of the oldest note
# TYPE trilium_oldest_note_timestamp gauge
trilium_oldest_note_timestamp 1746221741 1748291013

# HELP trilium_newest_note_timestamp Timestamp of the newest note
# TYPE trilium_newest_note_timestamp gauge
trilium_newest_note_timestamp 1747255397 1748291013

# HELP trilium_last_modified_timestamp Timestamp of the last modification
# TYPE trilium_last_modified_timestamp gauge
trilium_last_modified_timestamp 1747255432 1748291013

and then in JSON (in case someone wants it for something, or even for the Homepage implementation):

(v23.11.0) [root on DESKTOP-8EMKV7Q] ~/repos/TriliumNext/Notes on feat/metrics-endpoint:feat/metrics-endpoint
 Γ¥»  curl 'http://localhost:8080/etapi/metrics?format=json' -H "Authorization: lQsQRo00SfO4_G8nxsbhOWuWF3hzxcmQB8rviQz/Xg7cnEiv4Yu6blR4=" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   927  100   927    0     0  82451      0 --:--:-- --:--:-- --:--:-- 84272
{
  "version": {
    "app": "0.94.0",
    "db": 231,
    "node": "v23.11.0",
    "sync": 35,
    "buildDate": "2025-04-10T18:06:20Z",
    "buildRevision": "3df666b03e55a7719958a20cbd9e14601d7da580"
  },
  "database": {
    "totalNotes": 427,
    "deletedNotes": 0,
    "activeNotes": 427,
    "protectedNotes": 0,
    "totalAttachments": 18,
    "deletedAttachments": 0,
    "activeAttachments": 18,
    "totalRevisions": 1,
    "totalBranches": 441,
    "totalAttributes": 739,
    "totalBlobs": 147,
    "totalEtapiTokens": 1,
    "totalRecentNotes": 11,
    "totalEmbeddings": 0,
    "totalEmbeddingProviders": 1
  },
  "noteTypes": {
    "doc": 179,
    "text": 115,
    "code": 25,
    "launcher": 25,
    "book": 21,
    "contentWidget": 16,
    "mermaid": 13,
    "image": 12,
    "render": 7,
    "file": 5,
    "webView": 5,
    "canvas": 1,
    "geoMap": 1,
    "mindMap": 1,
    "noteMap": 1
  },
  "attachmentTypes": {
    "image/svg+xml": 16,
    "image/jpg": 2
  },
  "statistics": {
    "oldestNote": "2025-05-02 21:35:41.912Z",
    "newestNote": "2025-05-14 20:43:17.404Z",
    "lastModified": "2025-05-14 20:43:52.313Z",
    "databaseSizeBytes": 2514944
  },
  "timestamp": "2025-05-26T20:55:47.487Z"
}

@eliandoran eliandoran added this to the v0.94.0 milestone May 27, 2025
@eliandoran eliandoran merged commit 39f1c4e into develop May 27, 2025
11 checks passed
@eliandoran eliandoran deleted the feat/metrics-endpoint branch May 27, 2025 06:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

personal usage statistics
2 participants