-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
65 lines (51 loc) · 1.53 KB
/
Copy pathmain.go
File metadata and controls
65 lines (51 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"embed"
"io/fs"
"log"
"net/http"
"github.com/DPanel-dev/plugin-log-lens/analyzer"
"github.com/DPanel-dev/plugin-log-lens/handler"
"github.com/DPanel-dev/plugin-log-lens/receiver"
"github.com/DPanel-dev/plugin-log-lens/store"
"github.com/gin-gonic/gin"
)
//go:embed frontend/dist
var frontendFS embed.FS
func main() {
store.Init()
defer store.Close()
analyzer.Init()
store.ScanStaticPipelines()
go receiver.StartFluentd()
go receiver.StartSyslog()
go store.StartCleanup()
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
api := r.Group("/api")
{
api.GET("/pipelines", handler.ListPipelines)
api.POST("/pipelines/create", handler.CreatePipeline)
api.POST("/pipelines/update", handler.UpdatePipeline)
api.POST("/pipelines/delete", handler.DeletePipeline)
api.POST("/logs/query", handler.QueryLogs)
api.POST("/logs/tail", handler.TailLogs)
api.POST("/logs/search", handler.SearchLogs)
api.POST("/logs/export", handler.ExportLogs)
api.POST("/analyze", handler.AnalyzePipeline)
api.GET("/alerts", handler.ListAlerts)
api.POST("/alerts/read", handler.MarkAlertRead)
api.POST("/alerts/config", handler.UpdateAlertConfig)
api.GET("/stats", handler.GetStats)
api.GET("/stats/pipeline/:id", handler.GetPipelineStats)
}
dist, err := fs.Sub(frontendFS, "frontend/dist")
if err != nil {
log.Fatal("frontend load failed: ", err)
}
r.NoRoute(gin.WrapH(http.FileServer(http.FS(dist))))
log.Println("LogLens listening on :8080")
if err := r.Run(":8080"); err != nil {
log.Fatal(err)
}
}