{"id":26911563,"url":"https://github.com/tinybirdco/logs-explorer-template","last_synced_at":"2025-04-01T14:44:16.308Z","repository":{"id":275785543,"uuid":"927162252","full_name":"tinybirdco/logs-explorer-template","owner":"tinybirdco","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-24T11:53:16.000Z","size":952,"stargazers_count":60,"open_issues_count":1,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T12:25:36.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://logs.tinybird.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinybirdco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-02-04T14:07:15.000Z","updated_at":"2025-03-24T11:53:21.000Z","dependencies_parsed_at":"2025-02-04T15:45:15.939Z","dependency_job_id":"69081eff-570a-4f2a-beb4-588024f1eb36","html_url":"https://github.com/tinybirdco/logs-explorer-template","commit_stats":null,"previous_names":["tinybirdco/log-analytics-template","tinybirdco/logs-explorer-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinybirdco%2Flogs-explorer-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinybirdco%2Flogs-explorer-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinybirdco%2Flogs-explorer-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinybirdco%2Flogs-explorer-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinybirdco","download_url":"https://codeload.github.com/tinybirdco/logs-explorer-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246659334,"owners_count":20813324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-04-01T14:44:13.819Z","updated_at":"2025-04-01T14:44:15.514Z","avatar_url":"https://github.com/tinybirdco.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logs Explorer Template\n\nThis is a template for a Logs Explorer web application. It is built with Next.js and [Tinybird](https://tinybird.co).\n\nUse this template to bootstrap a multi-tenant, user-facing logs explorer for any software project. Fork it and make it your own!\n\nTech Stack:\n- Next.js\n- Tinybird\n- Clerk\n- Vercel\n- zod-bird\n- Tailwind CSS\n- Shadcn UI\n\n## Live Demo\n\n- [https://logs.tinybird.app](https://logs.tinybird.app)\n- [Watch Demo Video](https://tinybird-blog.ghost.io/content/media/2025/02/1-explorer-features-2.mp4)\n\n## Quick Start\n\nDeploy the Tinybird and Next.js to the cloud to get started quickly.\n\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://app.tinybird.co?starter_kit=https://github.com/tinybirdco/logs-explorer-template/tinybird\"\u003e\n    \u003cimg width=\"200\" src=\"https://img.shields.io/badge/Deploy%20to-Tinybird-25283d?style=flat\u0026labelColor=25283d\u0026color=27f795\u0026logo=data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNTAwIDUwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNTAwIDQyLjhsLTE1Ni4xLTQyLjgtNTQuOSAxMjIuN3pNMzUwLjcgMzQ1LjRsLTE0Mi45LTUxLjEtODMuOSAyMDUuN3oiIGZpbGw9IiNmZmYiIG9wYWNpdHk9Ii42Ii8+PHBhdGggZD0iTTAgMjE5LjlsMzUwLjcgMTI1LjUgNTcuNS0yNjguMnoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[![Deploy to Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Ftinybirdco%2Flogs-explorer-template\u0026project-name=tinybird-logs-explorer-template\u0026repository-name=tinybird-logs-explorer-template\u0026demo-description=Custom%20logs%20explorer%20for%20your%20application%20logs%20using%20Tinybird\u0026demo-url=http%3A%2F%2Flogs.tinybird.app\u0026demo-image=//github.com/tinybirdco/logs-explorer-template/blob/main/dashboard/log-analyzer/public/banner.png?raw=true\u0026root-directory=dashboard/log-analyzer)\n\nAppend the `tinybird/fixtures/logs.ndjson` file to the `logs` Data Source or stream some mock data.\n\nConfigure these Environment Variables in your Vercel project and you are ready to go:\n\n```bash\nNEXT_PUBLIC_TINYBIRD_API_KEY=\u003cYOUR_TINYBIRD_ADMIN_TOKEN\u003e\nNEXT_PUBLIC_TINYBIRD_API_URL=\u003cYOUR_TINYBIRD_REGION_HOST\u003e\n```\n\nGet your Tinybird admin token and region host from the Tinybird dashboard.\n\n## Local Development\n\nGet started by forking the [GitHub repository](https://github.com/tinybirdco/logs-explorer-template) and then customizing it to your needs.\n\nStart Tinybird locally:\n\n```bash\ncurl -LsSf https://tbrd.co/fwd | sh\ncd tinybird\ntb local start\ntb login\ntb dev\ntoken ls  # copy an admin token\n```\n\nConfigure the Next.js application:\n\n```bash\ncd dashboard/log-analyzer\ncp .env.example .env\n```\n\nEdit the `.env` file with your Tinybird API key and other configuration.\n\n```bash\nNEXT_PUBLIC_TINYBIRD_API_KEY=\u003cYOUR_TINYBIRD_LOCAL_ADMIN_TOKEN\u003e\nNEXT_PUBLIC_TINYBIRD_API_URL=http://localhost:7181\n```\n\nStart the Next.js application:\n\n```bash\ncd dashboard/log-analyzer\nnpm install\nnpm run dev\n```\n\nOpen the application in your browser:\n\n```bash\nhttp://localhost:3000\n```\n\nRead the [dashboard/log-analyzer/README.md](./dashboard/log-analyzer/README.md) file for more information on how to use the application and [tinybird/README.md](./tinybird/README.md) for more information on how to customize the template.\n\n## Multi-tenancy\n\nThe template is designed to be multi-tenant. It uses Clerk for authentication and user management.\n\nConfigure the `.env` file with your Clerk publishable key and secret.\n\n```bash\nCLERK_PUBLISHABLE_KEY=\u003cYOUR_CLERK_PUBLISHABLE_KEY\u003e\nCLERK_SECRET_KEY=\u003cYOUR_CLERK_SECRET_KEY\u003e\n```\n\nThen set the Tinybird JWT secret and workspace ID in the `.env` file.\n\n```bash\nTINYBIRD_JWT_SECRET=\u003cYOUR_TINYBIRD_ADMIN_TOKEN\u003e\nTINYBIRD_WORKSPACE_ID=\u003cYOUR_TINYBIRD_WORKSPACE_ID\u003e\n```\n\nModify the middleware to adapt the Tinybird token to your tenants.\n\n```typescript\n// dashboard/log-analyzer/src/middleware.ts\n\nconst token = await new jose.SignJWT({\n    workspace_id: process.env.TINYBIRD_WORKSPACE_ID,\n    name: `frontend_jwt_user_${userId}`,\n    exp: Math.floor(Date.now() / 1000) + (60 * 15), // 15 minute expiration\n    iat: Math.floor(Date.now() / 1000),\n    scopes: [\n      {\n        type: \"PIPES:READ\",\n        resource: \"log_analysis\",\n        fixed_params: { user_id: userId, org_permission: orgName, service: \"web\" }\n      },\n      {\n        type: \"PIPES:READ\",\n        resource: \"log_explorer\",\n        fixed_params: { user_id: userId, org_permission: orgName, service: \"web\" }\n      },\n      {\n        type: \"PIPES:READ\",\n        resource: \"generic_counter\",\n        fixed_params: { user_id: userId, org_permission: orgName, service: \"web\" }\n      },\n      {\n        type: \"PIPES:READ\",\n        resource: \"log_timeseries\",\n        fixed_params: { user_id: userId, org_permission: orgName, service: \"web\" }\n      }\n    ],\n    limits: {\n      rps: 10\n    }\n  })\n    .setProtectedHeader({ alg: 'HS256' })\n    .sign(secret);\n```\n\nRead more about how to integrate Clerk and Tinybird JWT tokens in [this guide](https://www.tinybird.co/docs/publish/api-endpoints/guides/multitenant-real-time-apis-with-clerk-and-tinybird).\n\n## Instrumenting your application\n\nTo instrument your application, just send JSON objects to the Tinybird [Events API](https://www.tinybird.co/docs/get-data-in/ingest-apis/events-api).\n\n```typescript\nconst data = {\n    timestamp: new Date().toISOString(),\n    level: 'info',\n    service: 'my-app',\n    message: 'This is a test message',\n    request_id: '1234567890',\n    environment: 'development',\n    status_code: 200,\n    response_time: 100,\n    request_method: 'GET',\n    request_path: '/',\n    host: 'my-app.com',\n    user_agent: req.headers.get('user-agent')\n}\nawait fetch(\n    `https://\u003cYOUR_TINYBIRD_HOST\u003e/v0/events?name=logs`,\n    {\n    method: 'POST',\n    body: JSON.stringify(data),\n    headers: { Authorization: `Bearer ${process.env.TINYBIRD_APPEND_TOKEN}` },\n    }\n)\n```\n\nThe example above uses the [logs](./tinybird/datasources/logs.datasource) Data Source and schema in this template but you can use your own Data Source and schema, append logs and build your own logs explorer application.\n\nCheck the [examples](./examples) folder for some examples of how to do this with different languages, services and schemas.\n\n## Building a log aggregator with Vector\n\nVector is a log aggregator that is used to collect, process, and store logs built by DataDog.\n\nYou can use Vector to collect logs from different sources and send them to a Tinybird Sink.\n\nCheck the [examples/vector](./examples/vector) folder for an example of how to do this with Vector.\n\n## Deployment\n\nDeploy the Tinybird project to the cloud:\n\n```bash\ncd tinybird\ntb --cloud deploy\n```\n\nOnce deployed copy your Tinybird cloud host and `read_pipes` token, [deploy the Next.js application to Vercel](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Ftinybirdco%2Flogs-explorer-template\u0026project-name=tinybird-logs-explorer-template\u0026repository-name=tinybird-logs-explorer-template\u0026demo-description=Custom%20logs%20explorer%20for%20your%20application%20logs%20using%20Tinybird\u0026demo-url=http%3A%2F%2Flogs.tinybird.app\u0026demo-image=//github.com/tinybirdco/logs-explorer-template/blob/main/dashboard/log-analyzer/public/banner.png?raw=true\u0026root-directory=dashboard/log-analyzer) and configure the environment variables.\n\n## Customizing the template\n\nYou can use the template as a starting point to build your own logs explorer application or embed components in your own application.\n\nTo customize the template, adapt the data sources and pipes in the [tinybird project](./tinybird) and the components in the [Next.js application](./dashboard/log-analyzer).\n\nSee how it's done in the [Vercel Log Drains template](https://github.com/alrocar/vercel-logs-explorer-template) and the [Auth0 Log Streams template](https://github.com/tinybirdco/auth0-logs-explorer-template).\n\n## Contributing\n\nPlease open an issue or submit a pull request.\n\n## Support\n\nJoin the Tinybird [Slack community](https://www.tinybird.co/community) to get help with your project.\n\n## License\n\nMIT License\n\nCopyright (c) 2025 Tinybird.co\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinybirdco%2Flogs-explorer-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinybirdco%2Flogs-explorer-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinybirdco%2Flogs-explorer-template/lists"}