{"id":29116591,"url":"https://github.com/iyashjayesh/monigo","last_synced_at":"2026-01-23T07:15:32.669Z","repository":{"id":256655662,"uuid":"846955441","full_name":"iyashjayesh/monigo","owner":"iyashjayesh","description":"MoniGo is a performance monitoring library for Go apps, offering real-time insights into service-level and function-level metrics. With an intuitive UI, it enables developers to track and optimize performance. Get your Go app's dashboard up in just 10 seconds!","archived":false,"fork":false,"pushed_at":"2026-01-22T03:27:18.000Z","size":78584,"stargazers_count":393,"open_issues_count":3,"forks_count":19,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-22T16:55:43.498Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/iyashjayesh/monigo","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iyashjayesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"iyashjayesh","ko_fi":"codingyash","buy_me_a_coffee":"codingyash"}},"created_at":"2024-08-24T12:38:48.000Z","updated_at":"2026-01-22T03:20:02.000Z","dependencies_parsed_at":"2024-09-15T01:57:33.784Z","dependency_job_id":"a132dede-055f-4308-aaab-062a456ca93d","html_url":"https://github.com/iyashjayesh/monigo","commit_stats":null,"previous_names":["iyashjayesh/monigo"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/iyashjayesh/monigo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashjayesh%2Fmonigo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashjayesh%2Fmonigo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashjayesh%2Fmonigo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashjayesh%2Fmonigo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iyashjayesh","download_url":"https://codeload.github.com/iyashjayesh/monigo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashjayesh%2Fmonigo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28682691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["hacktoberfest"],"created_at":"2025-06-29T11:13:42.634Z","updated_at":"2026-01-23T07:15:32.658Z","avatar_url":"https://github.com/iyashjayesh.png","language":"CSS","readme":"\u003c!-- ### Status: Testing going on for v1 release 🚀 --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./static/assets/monigo-icon.png\" width=\"200\" title=\"Monigo Icon\" alt=\"monigo-icon\"/\u003e\n\u003c/p\u003e\n\n# MoniGo - Performance Monitoring for Go Applications\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/iyashjayesh/monigo)](https://goreportcard.com/report/github.com/iyashjayesh/monigo)\n[![GoDoc](https://godoc.org/github.com/iyashjayesh/monigo?status.svg)](https://pkg.go.dev/github.com/iyashjayesh/monigo)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![Visitors](https://api.visitorbadge.io/api/visitors?path=iyashjayesh%2Fmonigo%20\u0026countColor=%23263759\u0026style=flat)\n![GitHub last commit](https://img.shields.io/github/last-commit/iyashjayesh/monigo)\n\u003c!-- \u003ca href=\"https://www.producthunt.com/posts/monigo?embed=true\u0026utm_source=badge-featured\u0026utm_medium=badge\u0026utm_souce=badge-monigo\" target=\"_blank\"\u003e\u003cimg src=\"https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=487815\u0026theme=light\" alt=\"MoniGO - Go\u0026#0032;App\u0026#0032;Performance\u0026#0032;Dashboard\u0026#0032;in\u0026#0032;10\u0026#0032;Seconds\u0026#0032;with\u0026#0032;R\u0026#0045;T\u0026#0032;Insight\u0026#0033; | Product Hunt\" style=\"width: 250px; height: 54px;\" width=\"250\" height=\"54\" /\u003e\u003c/a\u003e --\u003e\n\n\u003c!-- [![Github All Releases](https://img.shields.io/github/downloads/iyashjayesh/monigo/total.svg)](https://GitHub.com/iyashjayesh/monigo/releases/) --\u003e\n\n**MoniGo** is a performance monitoring library for Go applications. It provides real-time insights into application performance with an intuitive user interface, enabling developers to track and optimize both service-level and function-level metrics.\n\n\u003c!-- \u003cdiv align=\"center\" style=\"display: flex; flex-wrap: wrap; gap: 10px; border: 2px solid #ccc; padding: 10px;\"\u003e\n  \u003cimg src=\"./static/assets/ss/d1.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d10.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d2.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d7.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d8.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d3.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d4.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d5.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d6.png\" alt=\"Dashboard\" width=\"300\"\u003e\n  \u003cimg src=\"./static/assets/ss/d9.png\" alt=\"Dashboard\" width=\"300\"\u003e\n\u003c/div\u003e --\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"monigo.gif\" width=\"100%\" alt=\"monigo-gif\"\u003e\n\u003c/div\u003e\n\n## Features\n\n- **Real-Time Monitoring**: Access up-to-date performance metrics for your Go applications.\n- **Detailed Insights**: Track and analyze both service and function-level performance.\n- **Disk I/O Monitoring**: Monitor disk read/write bytes and system disk load.\n- **Customizable Dashboard**: Manage performance data with an easy-to-use UI.\n- **Visualizations**: Utilize graphs and charts to interpret performance trends.\n- **Custom Thresholds**: Configure custom thresholds for your application's performance and resource usage.\n\n## Installation\n\nTo install MoniGo, use the following command:\n\n```bash\ngo get github.com/iyashjayesh/monigo@latest\n```\n\n## Example:\n\n```go\npackage main\n\nimport (\n    \"github.com/iyashjayesh/monigo\"\n\t\"log\"\n\t\"math\"\n)\n\nfunc main() {\n    // New way: Use Builder Pattern for clean initialization\n    monigoInstance := monigo.NewBuilder().\n        WithServiceName(\"data-api\").\n        WithPort(8080).\n        WithRetentionPeriod(\"4d\").\n        WithDataPointsSyncFrequency(\"5s\").\n        Build()\n\n   \tmonigo.TraceFunction(highCPUUsage) // Trace function\n\n\tgo func() {\n        // Start returns an error now, so handle it!\n        if err := monigoInstance.Start(); err != nil {\n            log.Fatalf(\"Failed to start MoniGo: %v\", err)\n        }\n    }()\n\tlog.Printf(\"Monigo dashboard started at port %d\\n\", monigoInstance.GetRuningPort())\n\n  \t// Optional\n\t// routinesStats := monigoInstance.GetGoRoutinesStats() // Get go routines stats\n\t// log.Println(routinesStats)\n\n  \tselect {} // To keep the program running\n}\n\n// highCPUUsage is a function that simulates high CPU usage\nfunc highCPUUsage() {\n\t// Simulate high CPU usage by performing heavy computations\n\tvar sum float64\n\tfor i := 0; i \u003c 1e8; i++ { // 100 million iterations\n\t\tsum += math.Sqrt(float64(i))\n\t}\n}\n```\n\nFor more detailed usage instructions, refer to the documentation.\nBy default, the dashboard will be available at `http://localhost:8080/` else at the port you have provided.\n\n## Function Tracing\n\nMoniGo provides powerful function tracing capabilities to monitor the performance of your application functions. You can trace functions with any signature, including those with parameters and return values.\n\n### Available Tracing Methods\n\n#### 1. Legacy Method (Backward Compatible)\nThe original `TraceFunction` method for functions without parameters:\n\n```go\nfunc apiHandler(w http.ResponseWriter, r *http.Request) {\n    // Trace function: when the highMemoryUsage function is called, it will be traced.\n    monigo.TraceFunction(highMemoryUsage)\n    w.Write([]byte(\"API1 response: memexpensiveFunc\"))\n}\n\nfunc highMemoryUsage() {\n    // Simulate high memory usage by allocating a large slice\n    largeSlice := make([]float64, 1e8) // 100 million elements\n    for i := 0; i \u003c len(largeSlice); i++ {\n        largeSlice[i] = float64(i)\n    }\n}\n```\n\n#### 2. Enhanced Method - Functions with Parameters\nUse `TraceFunctionWithArgs` to trace functions that take parameters:\n\n```go\n// Business logic function with parameters\nfunc processUser(userID string, userName string) {\n    // Your business logic here\n    time.Sleep(100 * time.Millisecond)\n    _ = make([]byte, 1024*1024) // 1MB allocation\n}\n\nfunc userHandler(w http.ResponseWriter, r *http.Request) {\n    userID := r.URL.Query().Get(\"id\")\n    userName := r.URL.Query().Get(\"name\")\n    \n    // NEW WAY: Direct function tracing with parameters\n    monigo.TraceFunctionWithArgs(processUser, userID, userName)\n    \n    w.Write([]byte(\"User processed\"))\n}\n```\n\n#### 3. Enhanced Method - Functions with Return Values\nUse `TraceFunctionWithReturn` to trace functions that return values:\n\n```go\n// Business logic function with return value\nfunc calculateTotal(items []Item) float64 {\n    var total float64\n    for _, item := range items {\n        total += item.Price\n    }\n    return total\n}\n\nfunc calculateHandler(w http.ResponseWriter, r *http.Request) {\n    items := []Item{\n        {Name: \"Laptop\", Price: 999.99},\n        {Name: \"Mouse\", Price: 29.99},\n    }\n    \n    // NEW WAY: Trace function with return value\n    total := monigo.TraceFunctionWithReturn(calculateTotal, items).(float64)\n    \n    w.Write([]byte(fmt.Sprintf(\"Total: $%.2f\", total)))\n}\n```\n\n#### 4. Enhanced Method - Functions with Multiple Return Values\nUse `TraceFunctionWithReturns` to trace functions that return multiple values:\n\n```go\n// Business logic function with multiple return values\nfunc processData(data string) (Result, error) {\n    // Processing logic\n    if data == \"error\" {\n        return Result{}, fmt.Errorf(\"processing error\")\n    }\n    return Result{Success: true, Message: \"OK\"}, nil\n}\n\nfunc processHandler(w http.ResponseWriter, r *http.Request) {\n    data := \"test-data\"\n    \n    // NEW WAY: Trace function with multiple returns\n    results := monigo.TraceFunctionWithReturns(processData, data)\n    \n    if len(results) \u003e= 2 {\n        result := results[0].(Result)\n        err := results[1].(error)\n        \n        if err != nil {\n            w.WriteHeader(http.StatusInternalServerError)\n            w.Write([]byte(fmt.Sprintf(\"Error: %v\", err)))\n            return\n        }\n        \n        w.Write([]byte(fmt.Sprintf(\"Result: %+v\", result)))\n    }\n}\n```\n\n**Alternative: Using the first return value only**\n```go\n// For functions with multiple returns, you can still use TraceFunctionWithReturn\n// to get just the first return value\nresult := monigo.TraceFunctionWithReturn(processData, data).(Result)\n// Note: This ignores the error return value\n```\n\n### Benefits of Enhanced Tracing\n\n- **Cleaner Code**: No need to wrap functions in anonymous functions\n- **Better Function Identification**: Actual function names appear in metrics instead of anonymous functions\n- **Type Safety**: Compile-time checking of function signatures\n- **Flexibility**: Support for any function signature (parameters, return values, etc.)\n- **Backward Compatibility**: Existing code continues to work without changes\n\n### Function Name Generation\n\nThe enhanced tracing methods automatically generate descriptive function names that include:\n- Function name\n- Parameter types: `functionName(string,int)`\n- Return types: `functionName(string,int)-\u003e(float64,error)`\n\nThis makes it easier to identify and analyze specific function calls in the dashboard.\n\n### Handling Multiple Return Values\n\nWhen dealing with functions that return multiple values, you have several options:\n\n#### Option 1: Get All Return Values (Recommended)\n```go\nfunc processData(data string) (Result, error) {\n    // Your logic here\n    return result, nil\n}\n\n// Get all return values\nresults := monigo.TraceFunctionWithReturns(processData, data)\nresult := results[0].(Result)\nerr := results[1].(error)\n```\n\n#### Option 2: Get Only the First Return Value\n```go\n// Get only the first return value (ignores error)\nresult := monigo.TraceFunctionWithReturn(processData, data).(Result)\n```\n\n#### Option 3: Handle Different Return Counts\n```go\nresults := monigo.TraceFunctionWithReturns(myFunction, args...)\n\nswitch len(results) {\ncase 0:\n    // Function returns nothing\ncase 1:\n    // Function returns one value\n    value := results[0]\ncase 2:\n    // Function returns two values (common pattern: result, error)\n    value := results[0]\n    err := results[1].(error)\ncase 3:\n    // Function returns three values\n    value1 := results[0]\n    value2 := results[1]\n    err := results[2].(error)\ndefault:\n    // Function returns many values\n    // Handle accordingly\n}\n```\n\n### Example: Complete Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n    \"github.com/iyashjayesh/monigo\"\n)\n\nfunc main() {\n    monigoInstance := \u0026monigo.Monigo{\n        ServiceName: \"my-service\",\n        DashboardPort: 8080,\n    }\n    \n    go monigoInstance.Start()\n    \n    http.HandleFunc(\"/api/user\", userHandler)\n    http.HandleFunc(\"/api/calculate\", calculateHandler)\n    http.ListenAndServe(\":8000\", nil)\n}\n\n// Functions with different signatures\nfunc processUser(userID string, userName string) {\n    // Business logic\n}\n\nfunc calculateTotal(items []Item) float64 {\n    // Calculation logic\n    return 0.0\n}\n\nfunc userHandler(w http.ResponseWriter, r *http.Request) {\n    // Enhanced tracing - direct function calls\n    monigo.TraceFunctionWithArgs(processUser, \"123\", \"John\")\n    w.Write([]byte(\"User processed\"))\n}\n\nfunc calculateHandler(w http.ResponseWriter, r *http.Request) {\n    items := []Item{{Name: \"Item1\", Price: 10.0}}\n    \n    // Enhanced tracing - with return value\n    total := monigo.TraceFunctionWithReturn(calculateTotal, items).(float64)\n    w.Write([]byte(fmt.Sprintf(\"Total: %.2f\", total)))\n}\n```\n\n## Router Integration\n\nMoniGo now supports integration with your existing HTTP server, allowing you to use your own router and authorization system. This is perfect for applications that need to integrate MoniGo as part of their existing infrastructure.\n\n### Integration Options\n\n#### 1. Full Integration (Recommended)\nRegister all MoniGo handlers (both API and static files) to your existing HTTP mux:\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"net/http\"\n    \"github.com/iyashjayesh/monigo\"\n)\n\nfunc main() {\n    // Initialize MoniGo without starting the dashboard\n    monigoInstance := monigo.NewBuilder().\n        WithServiceName(\"my-service\").\n        WithDataPointsSyncFrequency(\"5m\").\n        WithRetentionPeriod(\"7d\").\n        WithTimeZone(\"Local\").\n        WithCustomBaseAPIPath(\"/monitoring/api/v1\").\n        Build()\n\n    // Initialize MoniGo (sets up metrics collection)\n    if err := monigoInstance.Initialize(); err != nil {\n        log.Fatalf(\"Failed to initialize MoniGo: %v\", err)\n    }\n\n    // Create your own HTTP mux\n    mux := http.NewServeMux()\n\n    // Register all MoniGo handlers to your mux\n    monigo.RegisterDashboardHandlers(mux, \"/monitoring/api/v1\")\n\n    // Add your own routes\n    mux.HandleFunc(\"/api/users\", usersHandler)\n    mux.HandleFunc(\"/health\", healthHandler)\n\n    log.Println(\"Server starting on :8080\")\n    log.Println(\"MoniGo dashboard: http://localhost:8080/\")\n    log.Println(\"MoniGo API: http://localhost:8080/monitoring/api/v1/\")\n\n    http.ListenAndServe(\":8080\", mux)\n}\n\nfunc usersHandler(w http.ResponseWriter, r *http.Request) {\n    // Trace functions for monitoring\n    monigo.TraceFunction(func() {\n        // Your function logic here\n    })\n    \n    w.Write([]byte(\"Users endpoint\"))\n}\n```\n\n#### 2. API-Only Integration\nRegister only MoniGo API endpoints (useful when you want to handle static files yourself):\n\n```go\n// Register only API handlers\nmonigo.RegisterAPIHandlers(mux, \"/monitoring/api/v1\")\n\n// Handle static files yourself\nmux.Handle(\"/static/\", http.StripPrefix(\"/static/\", http.FileServer(http.Dir(\"./static/\"))))\n```\n\n#### 3. Static-Only Integration\nRegister only MoniGo static file handlers (useful when you want to handle API routing yourself):\n\n```go\n// Register only static handlers\nmonigo.RegisterStaticHandlers(mux)\n\n// Handle API routing yourself\nmux.HandleFunc(\"/api/metrics\", customMetricsHandler)\n```\n\n#### 4. Maximum Flexibility\nGet handlers as a map for integration with any HTTP router (Gin, Echo, etc.):\n\n```go\n// Get API handlers as a map\napiHandlers := monigo.GetAPIHandlers(\"/monitoring/api/v1\")\n\n// Get static handler\nstaticHandler := monigo.GetStaticHandler()\n\n// Use with any router\nfor path, handler := range apiHandlers {\n    router.Any(path, gin.WrapF(handler)) // Example with Gin\n}\n```\n\n### Integration with Popular Frameworks\n\n#### Gin Framework\n```go\npackage main\n\nimport (\n    \"github.com/gin-gonic/gin\"\n    \"github.com/iyashjayesh/monigo\"\n)\n\nfunc main() {\n    monigoInstance := \u0026monigo.Monigo{\n        ServiceName: \"gin-service\",\n        // ... other config\n    }\n    monigoInstance.Initialize()\n\n    r := gin.Default()\n    \n    // Get and register MoniGo handlers\n    apiHandlers := monigo.GetAPIHandlers(\"/monigo/api/v1\")\n    for path, handler := range apiHandlers {\n        r.Any(path, gin.WrapF(handler))\n    }\n    \n    staticHandler := monigo.GetStaticHandler()\n    r.Any(\"/\", gin.WrapF(staticHandler))\n\n    r.Run(\":8080\")\n}\n```\n\n#### Echo Framework\n```go\npackage main\n\nimport (\n    \"github.com/labstack/echo/v4\"\n    \"github.com/iyashjayesh/monigo\"\n)\n\nfunc main() {\n    monigoInstance := \u0026monigo.Monigo{\n        ServiceName: \"echo-service\",\n        // ... other config\n    }\n    monigoInstance.Initialize()\n\n    e := echo.New()\n    \n    // Get and register MoniGo handlers\n    apiHandlers := monigo.GetAPIHandlers(\"/monigo/api/v1\")\n    for path, handler := range apiHandlers {\n        e.Any(path, echo.WrapHandler(http.HandlerFunc(handler)))\n    }\n    \n    staticHandler := monigo.GetStaticHandler()\n    e.Any(\"/\", echo.WrapHandler(http.HandlerFunc(staticHandler)))\n\n    e.Start(\":8080\")\n}\n```\n\n### Available Integration Functions\n\n| Function | Description |\n|----------|-------------|\n| `RegisterDashboardHandlers(mux, customPath)` | Register all handlers (API + static) |\n| `RegisterAPIHandlers(mux, customPath)` | Register only API handlers |\n| `RegisterStaticHandlers(mux)` | Register only static handlers |\n| `GetAPIHandlers(customPath)` | Get API handlers as a map |\n| `GetStaticHandler()` | Get static handler function |\n| `Initialize()` | Initialize MoniGo without starting dashboard |\n\n### Benefits of Router Integration\n\n- **Unified Server**: Run MoniGo on the same port as your application\n- **Custom Authorization**: Use your existing auth system to protect MoniGo endpoints\n- **Custom Routing**: Integrate with your existing routing patterns\n- **Framework Compatibility**: Works with any HTTP router (Gin, Echo, Chi, etc.)\n- **Flexible Configuration**: Choose which parts of MoniGo to integrate\n\n### Examples\n\nCheck out the complete examples in the `example/` directory:\n- `example/router-integration/` - Standard HTTP mux integration\n- `example/api-only-integration/` - API-only integration\n- `example/gin-integration/` - Gin framework integration\n- `example/echo-integration/` - Echo framework integration\n\n## Dashboard Security\n\nMoniGo now includes comprehensive security features to protect your dashboard and API endpoints in production environments. You can use built-in middleware or implement custom authentication to secure access to your monitoring data.\n\n### Security Features\n\n- **Built-in Middleware**: Pre-built security middleware for common use cases\n- **Custom Authentication**: Support for custom authentication functions\n- **Middleware Chains**: Chain multiple middleware for layered security\n- **Rate Limiting**: Built-in rate limiting to prevent abuse\n- **IP Restrictions**: IP whitelisting and blacklisting support\n- **Request Logging**: Comprehensive request logging for audit trails\n\n### Built-in Security Middleware\n\nMoniGo provides several built-in security middleware functions:\n\n#### Basic Authentication\n```go\nmonigo.BasicAuthMiddleware(\"username\", \"password\")\n```\n\n#### API Key Authentication\n```go\nmonigo.APIKeyMiddleware(\"your-secret-api-key\")\n```\n\n#### IP Whitelist\n```go\nmonigo.IPWhitelistMiddleware([]string{\"127.0.0.1\", \"192.168.1.0/24\"})\n```\n\n#### Rate Limiting\n```go\nmonigo.RateLimitMiddleware(100, time.Minute) // 100 requests per minute\n```\n\n#### Request Logging\n```go\nmonigo.LoggingMiddleware()\n```\n\n### Advanced Security Features\n\n#### Static File Handling\nMoniGo automatically bypasses authentication for static files (CSS, JS, images, etc.) to ensure the dashboard UI loads correctly:\n\n```go\n// Static files are automatically excluded from authentication\n// This includes: .css, .js, .png, .jpg, .gif, .svg, .ico, .woff, .woff2, etc.\n// And paths: /css/, /js/, /assets/, /images/, /fonts/, /static/\n```\n\n#### IP Whitelist with Debug Logging\nThe IP whitelist middleware includes comprehensive debug logging to help troubleshoot access issues:\n\n```go\n// IP whitelist with debug logging\nmonigo.IPWhitelistMiddleware([]string{\n    \"127.0.0.1\",      // IPv4 localhost\n    \"::1\",            // IPv6 localhost\n    \"192.168.1.0/24\", // Local network\n    \"10.0.0.0/8\",     // Private network\n})\n```\n\n#### Router-Specific Handlers\nMoniGo provides framework-specific handlers for seamless integration:\n\n```go\n// Gin Framework\nginHandler := monigo.GetGinHandler(\"/monigo/api/v1\")\n\n// Echo Framework  \nechoHandler := monigo.GetEchoHandler(\"/monigo/api/v1\")\n\n// Fiber Framework\nfiberHandler := monigo.GetFiberHandler(\"/monigo/api/v1\")\n```\n\n### Security Configuration\n\n#### Using Built-in Middleware\n\n```go\nmonigoInstance := monigo.NewBuilder().\n    WithServiceName(\"my-service\").\n    \n    // Dashboard security (for static files)\n    WithDashboardMiddleware(\n        monigo.BasicAuthMiddleware(\"admin\", \"password\"),\n        monigo.LoggingMiddleware(),\n    ).\n    \n    // API security (for API endpoints)\n    WithAPIMiddleware(\n        monigo.APIKeyMiddleware(\"api-key\"),\n        monigo.RateLimitMiddleware(100, time.Minute),\n    ).\n    Build()\n```\n\n#### Using Custom Authentication\n\n```go\nmonigoInstance := monigo.NewBuilder().\n    WithServiceName(\"my-service\").\n    \n    // Custom authentication function\n    WithAuthFunction(func(r *http.Request) bool {\n        return r.Header.Get(\"X-API-Key\") == \"secret-key\"\n    }).\n    Build()\n```\n\n### Secured Handler Functions\n\nMoniGo provides secured versions of all handler functions:\n\n| Function | Description |\n|----------|-------------|\n| `GetSecuredUnifiedHandler(m, customPath)` | Get unified handler with middleware |\n| `GetSecuredAPIHandlers(m, customPath)` | Get API handlers with middleware |\n| `GetSecuredStaticHandler(m)` | Get static handler with middleware |\n| `StartSecuredDashboard(m)` | Start dashboard with middleware |\n| `RegisterSecuredDashboardHandlers(mux, m, customPath)` | Register secured dashboard handlers |\n| `RegisterSecuredAPIHandlers(mux, m, customPath)` | Register secured API handlers |\n| `RegisterSecuredStaticHandlers(mux, m)` | Register secured static handlers |\n\n### Security Examples\n\nCheck out the comprehensive security examples in the `example/security-examples/` directory:\n\n#### Core Security Examples\n- **Basic Authentication** (`basic-auth/`) - HTTP Basic Auth with rate limiting\n- **API Key Authentication** (`api-key/`) - API key via header/query parameter  \n- **IP Whitelist** (`ip-whitelist-example/`) - IP-based access control with debug logging\n- **Custom Authentication** (`custom-auth/`) - Custom auth function with headers/query params\n\n#### Router Integration Examples\n- **Gin Integration** (`gin/`) - Gin framework with security middleware\n- **Echo Integration** (`echo/`) - Echo framework with security middleware\n- **Fiber Integration** (`fiber/`) - Fiber framework with security middleware\n- **Chi Integration** (`chi/`) - Chi router with security middleware\n\n#### Running Security Examples\n\nEach example has its own `go.mod` file and can be run independently:\n\n```bash\n# Basic Authentication Example\ncd example/security-examples/basic-auth\ngo run .\n\n# API Key Example  \ncd example/security-examples/api-key\ngo run .\n\n# IP Whitelist Example\ncd example/security-examples/ip-whitelist-example\ngo run .\n\n# Custom Authentication Example\ncd example/security-examples/custom-auth\ngo run .\n\n# Router Integration Examples\ncd example/security-examples/gin\ngo run .\n\ncd example/security-examples/echo\ngo run .\n\ncd example/security-examples/fiber\ngo run .\n\ncd example/security-examples/chi\ngo run .\n```\n\n#### Example Access URLs\n\n- **Basic Auth**: `http://localhost:8080/` (username: `admin`, password: `monigo-secure-2024`)\n- **API Key**: `http://localhost:8080/?api_key=monigo-secret-key-2024`\n- **IP Whitelist**: `http://localhost:8080/` (localhost only)\n- **Custom Auth**: `http://localhost:8080/?secret=monigo-admin-secret` or with headers\n- **Router Examples**: Same URLs as above with framework-specific implementations\n\n### JavaScript Authentication Integration\n\nMoniGo's dashboard JavaScript automatically handles authentication for different security methods:\n\n#### API Key Authentication\nThe dashboard automatically detects API keys from URL parameters and includes them in all API requests:\n\n```javascript\n// Automatically extracts api_key from URL and includes in requests\n// URL: http://localhost:8080/?api_key=your-secret-key\n// All API calls will include: ?api_key=your-secret-key\n```\n\n#### Basic Authentication\nFor basic auth, the browser handles credentials automatically when prompted:\n\n```javascript\n// Browser automatically includes Authorization header\n// No additional JavaScript configuration needed\n```\n\n#### Custom Authentication\nSupports custom headers and query parameters:\n\n```javascript\n// Automatically adds custom headers and query parameters\n// Based on URL parameters or predefined authentication logic\n```\n\n### Production Security Best Practices\n\n1. **Use Strong Credentials**: Always use strong, unique passwords and API keys\n2. **Enable HTTPS**: Always use HTTPS in production environments\n3. **Implement Rate Limiting**: Use rate limiting to prevent abuse\n4. **IP Restrictions**: Use IP whitelisting for internal networks\n5. **Request Logging**: Enable logging to monitor access patterns\n6. **Regular Rotation**: Regularly rotate API keys and passwords\n7. **Environment Variables**: Store credentials in environment variables\n8. **Monitor Access**: Set up monitoring and alerting for security events\n9. **Static File Security**: Static files (CSS, JS, images) bypass authentication automatically\n10. **Debug Logging**: Use debug logging to monitor authentication attempts\n11. **Router Compatibility**: Test security middleware with your chosen HTTP framework\n12. **JavaScript Integration**: Ensure dashboard JavaScript handles your authentication method\n\n### Security Troubleshooting\n\n#### Common Issues and Solutions\n\n**Issue: Dashboard loads but CSS/JS files show 401 Unauthorized**\n- **Solution**: Static files should bypass authentication automatically. Check that `isStaticFile()` function is working correctly.\n\n**Issue: IP Whitelist blocking localhost access**\n- **Solution**: Add both IPv4 (`127.0.0.1`) and IPv6 (`::1`) localhost addresses to your whitelist.\n\n**Issue: API calls failing with authentication errors**\n- **Solution**: Ensure JavaScript is including authentication credentials. Check browser network tab for request headers/parameters.\n\n**Issue: Router integration not working**\n- **Solution**: Use the appropriate framework-specific handler (`GetGinHandler`, `GetEchoHandler`, `GetFiberHandler`).\n\n**Issue: Rate limiting too restrictive**\n- **Solution**: Adjust rate limit parameters: `RateLimitMiddleware(requests, timeWindow)`.\n\n#### Debug Mode\nEnable debug logging to troubleshoot authentication issues:\n\n```go\n// Add debug middleware to see what's happening\nDashboardMiddleware: []func(http.Handler) http.Handler{\n    debugMiddleware(), // Your custom debug middleware\n    monigo.LoggingMiddleware(),\n    // ... other middleware\n}\n```\n\n### Quick Start with Security\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"net/http\"\n    \"time\"\n    \n    \"github.com/iyashjayesh/monigo\"\n)\n\nfunc main() {\n    // Initialize MoniGo with security\n    monigoInstance := \u0026monigo.Monigo{\n        ServiceName: \"secure-service\",\n        DashboardMiddleware: []func(http.Handler) http.Handler{\n            monigo.BasicAuthMiddleware(\"admin\", \"secure-password\"),\n            monigo.LoggingMiddleware(),\n        },\n        APIMiddleware: []func(http.Handler) http.Handler{\n            monigo.RateLimitMiddleware(100, time.Minute),\n        },\n    }\n    \n    // Initialize and start secured dashboard\n    monigoInstance.Initialize()\n    \n    if err := monigo.StartSecuredDashboard(monigoInstance); err != nil {\n        log.Fatal(\"Failed to start secured dashboard:\", err)\n    }\n}\n```\n\n## Bellow Reports are available\n\n#### Note: You can download the reports in excel format.\n\n1. **Load Statistics**: Provides an overview of the overall load of the service, CPU load, memory load, and system load.\n\n| Field Name                | Value (Datatype) |\n| ------------------------- | ---------------- |\n| `overall_load_of_service` | `float64`        |\n| `service_cpu_load`        | `float64`        |\n| `service_memory_load`     | `float64`        |\n| `system_cpu_load`         | `float64`        |\n| `system_memory_load`      | `float64`        |\n\n2. **CPU Statistics**: Displays the total number of cores, cores used by the service, and cores used by the system.\n\n| Field Name              | Value (Datatype) |\n| ----------------------- | ---------------- |\n| `total_cores`           | `int`            |\n| `cores_used_by_service` | `int`            |\n| `cores_used_by_system`  | `int`            |\n\n3. **Memory Statistics**: Shows the total system memory, memory used by the system, memory used by the service, available memory, GC pause duration, and stack memory usage.\n\n| Field Name               | Value (Datatype) |\n| ------------------------ | ---------------- |\n| `total_system_memory`    | `float64`        |\n| `memory_used_by_system`  | `float64`        |\n| `memory_used_by_service` | `float64`        |\n| `available_memory`       | `float64`        |\n| `gc_pause_duration`      | `float64`        |\n| `stack_memory_usage`     | `float64`        |\n\n4. **Memory Profile**: Provides information on heap allocation by the service, heap allocation by the system, total allocation by the service, and total memory by the OS.\n\n| Field Name               | Value (Datatype) |\n| ------------------------ | ---------------- |\n| `heap_alloc_by_service`  | `float64`        |\n| `heap_alloc_by_system`   | `float64`        |\n| `total_alloc_by_service` | `float64`        |\n| `total_memory_by_os`     | `float64`        |\n\n5. **Network IO**: Displays the number of bytes sent and received.\n\n| Field Name       | Value (Datatype) |\n| ---------------- | ---------------- |\n| `bytes_sent`     | `float64`        |\n| `bytes_received` | `float64`        |\n\n6. **Health Metrics**: Provides an overall health percentage for the service.\n\n| Field Name               | Value (Datatype) |\n| ------------------------ | ---------------- |\n| `service_health_percent` | `float64`        |\n| `system_health_percent`  | `float64`        |\n\n## API Reference\n\n- You can access the MoniGo API by visiting the following URL: http://localhost:8080/monigo/api/v1/\u003cendpoint\u003e (replace `\u003cendpoint\u003e` with the desired endpoint).\n- **Note**: When using router integration, the API path can be customized using the `CustomBaseAPIPath` field or by passing a custom path to the registration functions.\n- API endpoints are available for the following:\n\n| Endpoint                           | Description           | Method | Request                                               | Response | Example                                            |\n| ---------------------------------- | --------------------- | ------ | ----------------------------------------------------- | -------- | -------------------------------------------------- |\n| `/monigo/api/v1/metrics`           | Get all metrics       | GET    | None                                                  | JSON     | [Example](./static/API/Res/metrics.json)           |\n| `/monigo/api/v1/go-routines-stats` | Get go routines stats | GET    | None                                                  | JSON     | [Example](./static/API/Res/go-routines-stats.json) |\n| `/monigo/api/v1/service-info`      | Get service info      | GET    | None                                                  | JSON     | [Example](./static/API/Res/service-info.json)      |\n| `/monigo/api/v1/service-metrics`   | Get service metrics   | POST   | JSON [Example](./static/API/Req/service-metrics.json) | JSON     | [Example](./static/API/Res/service-metrics.json)   |\n| `/monigo/api/v1/reports`           | Get history data      | POST   | JSON [Example](./static/API/Req/reports.json)         | JSON     | [Example](./static/API/Res/reports.json)           |\n\n## Contributing\n\nWe welcome contributions! If you encounter any issues or have suggestions, please submit a pull request or open an issue.\n\n**If you find MoniGo useful, consider giving it a star! ⭐**\n\n## Contact\n\nFor questions or feedback, please open an issue or contact me at `iyashjayesh@gmail.com` or at [LinkedIn](https://www.linkedin.com/in/iyashjayesh/)\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=iyashjayesh/monigo\u0026type=Date)](https://star-history.com/#iyashjayesh/monigo\u0026Date)\n\n## License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE file](https://github.com/iyashjayesh/monigo?tab=Apache-2.0-1-ov-file) for details.\n","funding_links":["https://github.com/sponsors/iyashjayesh","https://ko-fi.com/codingyash","https://buymeacoffee.com/codingyash"],"categories":["Go Tools","Go 工具"],"sub_categories":["Routers","Search and Analytic Databases","路由器"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyashjayesh%2Fmonigo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiyashjayesh%2Fmonigo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyashjayesh%2Fmonigo/lists"}