{"id":48974988,"url":"https://github.com/milosmiric/mongodb-datasource","last_synced_at":"2026-04-18T08:30:41.560Z","repository":{"id":342312136,"uuid":"1172884881","full_name":"milosmiric/mongodb-datasource","owner":"milosmiric","description":"MongoDB datasource plugin for Grafana - query collections using aggregation pipelines with built-in time-range macros, smart filtering, and full BSON type support.","archived":false,"fork":false,"pushed_at":"2026-04-09T06:27:35.000Z","size":2284,"stargazers_count":0,"open_issues_count":9,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-09T08:22:45.060Z","etag":null,"topics":["aggregation-pipleline","bson","grafana","grafana-dashboard","grafana-datasource","grafana-plugin","mongodb","mongodb-atlas","nosql","time-series"],"latest_commit_sha":null,"homepage":"https://miric.dev/projects/mongodb-datasource","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milosmiric.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-04T19:41:58.000Z","updated_at":"2026-03-09T09:07:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/milosmiric/mongodb-datasource","commit_stats":null,"previous_names":["milosmiric/mongodb-datasource"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/milosmiric/mongodb-datasource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milosmiric%2Fmongodb-datasource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milosmiric%2Fmongodb-datasource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milosmiric%2Fmongodb-datasource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milosmiric%2Fmongodb-datasource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milosmiric","download_url":"https://codeload.github.com/milosmiric/mongodb-datasource/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milosmiric%2Fmongodb-datasource/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aggregation-pipleline","bson","grafana","grafana-dashboard","grafana-datasource","grafana-plugin","mongodb","mongodb-atlas","nosql","time-series"],"created_at":"2026-04-18T08:30:40.825Z","updated_at":"2026-04-18T08:30:41.549Z","avatar_url":"https://github.com/milosmiric.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/milosmiric/mongodb-datasource/main/src/img/logo.svg\" width=\"80\" height=\"80\" alt=\"MongoDB Datasource Plugin\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eMongoDB Datasource Plugin for Grafana\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/milosmiric/mongodb-datasource/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/milosmiric/mongodb-datasource\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/milosmiric/mongodb-datasource/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/milosmiric/mongodb-datasource/ci.yml?branch=main\u0026label=CI\" alt=\"CI\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  A production-quality, open-source MongoDB datasource plugin for Grafana.\u003cbr\u003e\n  Query MongoDB collections using aggregation pipelines with built-in macros, smart filtering, and full BSON type support.\n\u003c/p\u003e\n\n## Why This Plugin?\n\nThe official Grafana MongoDB plugin is **Enterprise-only**. The best community alternative is pre-release (v0.5.x). This plugin fills the gap with:\n\n- Go backend for secure, high-performance MongoDB communication\n- Raw aggregation pipeline queries with template variable support\n- Built-in macros: `$__timeFilter(field)`, `$__timeGroup(field)`, `$__oidFilter(field)`, `$__timeFilter_ms(field)`\n- Smart `$__match` stage: index-friendly multi-select and \"All\" handling (replaces `$regex`)\n- 15+ built-in variables: time range, ObjectId, interval decomposition, panel resolution\n- Time-series and table output formats\n- Full BSON type conversion (ObjectID, Decimal128, Date, arrays, embedded docs, etc.)\n- Docker Compose development environment with sample data out of the box\n\n## Screenshots\n\n### Sample Dashboard — Time Series, Gauges \u0026 Aggregations\n![Dashboard - Sensors \u0026 Aggregations](https://raw.githubusercontent.com/milosmiric/mongodb-datasource/main/src/img/dashboard-1.png)\n\n### Sample Dashboard — Orders Analytics \u0026 BSON Types\n![Dashboard - Orders \u0026 BSON Types](https://raw.githubusercontent.com/milosmiric/mongodb-datasource/main/src/img/dashboard-2.png)\n\n### Configuration\n![Config Editor](https://raw.githubusercontent.com/milosmiric/mongodb-datasource/main/src/img/add-connection.png)\n\n## Quick Start\n\n```bash\ndocker compose up\n```\n\nOpen [http://localhost:3105](http://localhost:3105) (admin/admin). The MongoDB datasource and a sample dashboard are pre-configured with demo data.\n\n## Installation\n\n### Unsigned Plugin (Manual)\n\nThe plugin is pending Grafana catalog approval. Until then, install it manually:\n\n1. Download the latest `.zip` from [GitHub Releases](https://github.com/milosmiric/mongodb-datasource/releases)\n2. Extract to your Grafana plugins directory:\n   ```bash\n   unzip milosmiric-mongodb-datasource-*.zip -d /var/lib/grafana/plugins/\n   ```\n3. Allow the unsigned plugin in your Grafana configuration (`grafana.ini`):\n   ```ini\n   [plugins]\n   allow_loading_unsigned_plugins = milosmiric-mongodb-datasource\n   ```\n   Or via environment variable:\n   ```\n   GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=milosmiric-mongodb-datasource\n   ```\n4. Restart Grafana\n\n### Docker / Docker Compose\n\nAdd the environment variable to your Grafana container:\n\n```yaml\nenvironment:\n  GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: milosmiric-mongodb-datasource\nvolumes:\n  - ./path/to/milosmiric-mongodb-datasource:/var/lib/grafana/plugins/milosmiric-mongodb-datasource\n```\n\n### Grafana CLI (after catalog approval)\n\n```bash\ngrafana-cli plugins install milosmiric-mongodb-datasource\n```\n\n## Configuration\n\nPoint the datasource at your MongoDB instance using a connection URI:\n\n```\nmongodb://username:password@host:port/database\n```\n\nSupports SCRAM-SHA-256, SCRAM-SHA-1, X.509 authentication, TLS/SSL, and Atlas SRV connections.\n\nSee [docs/configuration.md](https://github.com/milosmiric/mongodb-datasource/blob/main/docs/configuration.md) for the full configuration guide including provisioning examples.\n\n## Query Examples\n\nQueries use MongoDB [aggregation pipelines](https://www.mongodb.com/docs/manual/core/aggregation-pipeline/). Select a database and collection, then write a pipeline as a JSON array.\n\n**Time series** — sensor readings scoped to the dashboard time range:\n\n```json\n[\n  {\"$match\": {$__timeFilter(timestamp)}},\n  {\"$sort\": {\"timestamp\": 1}},\n  {\"$project\": {\"_id\": 0, \"timestamp\": 1, \"value\": 1, \"location\": 1}}\n]\n```\n\n**Table** — recent documents:\n\n```json\n[\n  {\"$sort\": {\"timestamp\": -1}},\n  {\"$limit\": 100},\n  {\"$project\": {\"_id\": 0, \"name\": 1, \"email\": 1, \"role\": 1}}\n]\n```\n\n**Aggregation** — group and count:\n\n```json\n[\n  {\"$group\": {\"_id\": \"$type\", \"count\": {\"$sum\": 1}}},\n  {\"$sort\": {\"count\": -1}}\n]\n```\n\nBuilt-in macros (`$__timeFilter`, `$__timeGroup`, `$__oidFilter`, `$__timeFilter_ms`), smart match (`$__match`), and 15+ template variables. See [docs/template-variables.md](https://github.com/milosmiric/mongodb-datasource/blob/main/docs/template-variables.md) for the complete reference.\n\nSee [docs/queries.md](https://github.com/milosmiric/mongodb-datasource/blob/main/docs/queries.md) for the full query guide with patterns for time bucketing, joins, variable dropdowns, and performance tips.\n\n## Development\n\n### Prerequisites\n\n- [Node.js](https://nodejs.org/) \u003e= 22\n- [Go](https://go.dev/) \u003e= 1.23\n- [Mage](https://magefile.org/) (Go build tool)\n- [Docker](https://www.docker.com/) and Docker Compose\n\n### Build \u0026 Run\n\n```bash\nnpm install                   # Install frontend dependencies\nmake build                    # Build frontend + backend\nmake up                       # Start Grafana + MongoDB\n```\n\n### Common Commands\n\nAll development tasks are available as `make` targets. Run `make help` for the full list.\n\n| Command | Description |\n|---------|-------------|\n| `make build` | Build frontend and backend |\n| `make dev` | Start frontend in watch mode |\n| `make test` | Run all tests (Go + Jest) |\n| `make lint` | Run all linters |\n| `make up` / `make down` | Start / stop Docker environment |\n| `make rebuild` | Build everything and restart Grafana |\n| `make db-seed` | Seed MongoDB with demo data |\n| `make db-reset` | Drop demo database and re-seed |\n| `make db-random` | Insert 500 random sensor readings |\n| `make health` | Check Grafana and datasource health |\n| `make fresh` | Full clean rebuild from scratch |\n\nSee [docs/development.md](https://github.com/milosmiric/mongodb-datasource/blob/main/docs/development.md) for the full development guide covering architecture, debugging, CI/CD, and project structure.\n\n## Architecture\n\n```mermaid\ngraph LR\n    A[Grafana Frontend] --\u003e|gRPC| B[Go Backend Plugin]\n    B --\u003e|mongo-driver/v2| C[MongoDB]\n    A --\u003e|React Components| D[Query Editor]\n    A --\u003e|React Components| E[Config Editor]\n    D --\u003e|HTTP Resource| B\n    E --\u003e|HTTP Resource| B\n```\n\n- **Frontend** (`src/`): React/TypeScript — config editor, query editor, data fetching hooks\n- **Backend** (`pkg/`): Go — MongoDB connections, aggregation pipeline execution, BSON→DataFrame conversion\n- **Communication**: `DataSourceWithBackend` proxies queries to the Go backend via gRPC\n\n## Roadmap\n\nFuture milestones:\n\n- Visual query builder (drag-and-drop pipeline stages)\n- Change streams / live streaming\n- Schema introspection and field autocomplete\n- Alerting-specific features\n- Annotation queries\n- Explore integration\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/milosmiric/mongodb-datasource/blob/main/CONTRIBUTING.md) for branch naming, PR process, code style, and test requirements.\n\n## Author\n\n**Miloš Mirić** — Senior Solutions Architect at MongoDB\n\n- Website: [miric.dev](https://miric.dev)\n- LinkedIn: [milosmiric](https://www.linkedin.com/in/milosmiric/)\n- GitHub: [milosmiric](https://github.com/milosmiric)\n\n## License\n\nGNU Affero General Public License v3.0. See [LICENSE](https://github.com/milosmiric/mongodb-datasource/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilosmiric%2Fmongodb-datasource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilosmiric%2Fmongodb-datasource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilosmiric%2Fmongodb-datasource/lists"}