adding health check for tenzir

This commit is contained in:
Hari Krishna
2024-06-23 16:49:17 +00:00
committed by satti-hari-krishna-reddy
parent ecfb78e82d
commit 73b9b31fa6
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -5131,7 +5131,6 @@ func initHandlers() {
r.HandleFunc("/api/v1/triggers/pipeline", shuffle.HandleNewPipelineRegister).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/triggers/pipeline", shuffle.HandleNewPipelineRegister).Methods("POST", "OPTIONS")
//r.HandleFunc("/api/v1/triggers/pipeline/save", shuffle.HandleSavePipelineInfo).Methods("PUT", "OPTIONS") //r.HandleFunc("/api/v1/triggers/pipeline/save", shuffle.HandleSavePipelineInfo).Methods("PUT", "OPTIONS")
r.HandleFunc("/api/v1/pipelines/{key}", handlePipelineCallback).Methods("POST", "GET", "PATCH", "PUT", "DELETE", "OPTIONS") r.HandleFunc("/api/v1/pipelines/{key}", handlePipelineCallback).Methods("POST", "GET", "PATCH", "PUT", "DELETE", "OPTIONS")
r.HandleFunc("/api/v1/pipelines/tenzir_node_health", handleTenzirHealthUpdate).Methods("POST","OPTIONS")
r.HandleFunc("/api/v1/triggers", shuffle.HandleGetTriggers).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/triggers", shuffle.HandleGetTriggers).Methods("GET", "OPTIONS")
//r.HandleFunc("/api/v1/triggers/gmail/routing", handleGmailRouting).Methods("POST", "OPTIONS") //r.HandleFunc("/api/v1/triggers/gmail/routing", handleGmailRouting).Methods("POST", "OPTIONS")
@@ -5200,6 +5199,7 @@ func initHandlers() {
r.HandleFunc("/api/v1/files/detection/sigma_rules", shuffle.HandleGetSigmaRules).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/files/detection/sigma_rules", shuffle.HandleGetSigmaRules).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/files/detection/{fileId}/{action}", shuffle.HandleToggleRule).Methods("PUT", "OPTIONS") r.HandleFunc("/api/v1/files/detection/{fileId}/{action}", shuffle.HandleToggleRule).Methods("PUT", "OPTIONS")
r.HandleFunc("/api/v1/files/detection/{action}", shuffle.HandleFolderToggle).Methods("PUT", "OPTIONS") r.HandleFunc("/api/v1/files/detection/{action}", shuffle.HandleFolderToggle).Methods("PUT", "OPTIONS")
r.HandleFunc("/api/v1/detection/siem/node_health", handleTenzirHealthUpdate).Methods("POST","OPTIONS")
// Introduced in 0.9.21 to handle notifications for e.g. failed Workflow // Introduced in 0.9.21 to handle notifications for e.g. failed Workflow
r.HandleFunc("/api/v1/notifications", shuffle.HandleCreateNotification).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/notifications", shuffle.HandleCreateNotification).Methods("POST", "OPTIONS")
+4 -4
View File
@@ -1913,6 +1913,7 @@ func main() {
log.Printf("[INFO] Waiting for executions at %s with Environment %#v", fullUrl, environment) log.Printf("[INFO] Waiting for executions at %s with Environment %#v", fullUrl, environment)
hasStarted := false hasStarted := false
for { for {
_ = sendTenzirHealthStatus()
if req.Method == "POST" { if req.Method == "POST" {
// Should find data to send (memory etc.) // Should find data to send (memory etc.)
@@ -2260,7 +2261,6 @@ func main() {
} }
} }
_ = sendTenzirHealthStatus()
time.Sleep(time.Duration(sleepTime) * time.Second) time.Sleep(time.Duration(sleepTime) * time.Second)
} }
} }
@@ -2580,7 +2580,7 @@ func deployTenzirNode() error {
} }
func checkTenzirNode() error { func checkTenzirNode() error {
retries := 20 retries := 5
retryInterval := 3 * time.Second retryInterval := 3 * time.Second
url := fmt.Sprintf("%s/api/v0/ping",tenzirUrl) url := fmt.Sprintf("%s/api/v0/ping",tenzirUrl)
forwardMethod := "POST" forwardMethod := "POST"
@@ -3075,7 +3075,7 @@ func removePath(containerName, path string) error {
func sendTenzirHealthStatus() error { func sendTenzirHealthStatus() error {
var status string var status string
url := fmt.Sprintf("%s/api/v1/triggers/pipeline/tenzir_node_health", baseUrl) url := fmt.Sprintf("%s/api/v1/detection/siem/node_health", baseUrl)
err := checkTenzirNode() err := checkTenzirNode()
if err != nil { if err != nil {
return err return err
@@ -3116,7 +3116,7 @@ func sendTenzirHealthStatus() error {
log.Printf("[ERROR] Received non-successful HTTP status code: %d", resp.StatusCode) log.Printf("[ERROR] Received non-successful HTTP status code: %d", resp.StatusCode)
return fmt.Errorf("unexpected HTTP status code: %d", resp.StatusCode) return fmt.Errorf("unexpected HTTP status code: %d", resp.StatusCode)
} }
log.Printf("this is send successfully")
return nil return nil
} }