mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-21 10:06:58 +00:00
Adding the upload interval as parameter to tap function
This commit is contained in:
@@ -159,7 +159,7 @@ func UploadEntries(c *fiber.Ctx) error {
|
|||||||
return c.Status(fiber.StatusServiceUnavailable).SendString("Can't get token")
|
return c.Status(fiber.StatusServiceUnavailable).SendString("Can't get token")
|
||||||
}
|
}
|
||||||
rlog.Infof("Upload entries - uploading. token: %s model: %s\n", token.Token, token.Model)
|
rlog.Infof("Upload entries - uploading. token: %s model: %s\n", token.Token, token.Model)
|
||||||
go up9.UploadEntriesImpl(token.Token, token.Model, uploadRequestBody.Dest)
|
go up9.UploadEntriesImpl(token.Token, token.Model, uploadRequestBody.Dest, uploadRequestBody.sleepIntervalSec)
|
||||||
return c.Status(fiber.StatusOK).SendString("OK")
|
return c.Status(fiber.StatusOK).SendString("OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,8 +100,6 @@ func (fedex *FullEntryDetailsExtra) UnmarshalData(entry *MizuEntry) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type EntryData struct {
|
type EntryData struct {
|
||||||
Entry string `json:"entry,omitempty"`
|
Entry string `json:"entry,omitempty"`
|
||||||
ResolvedDestination string `json:"resolvedDestination,omitempty" gorm:"column:resolvedDestination"`
|
ResolvedDestination string `json:"resolvedDestination,omitempty" gorm:"column:resolvedDestination"`
|
||||||
@@ -114,7 +112,8 @@ type EntriesFilter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UploadEntriesRequestBody struct {
|
type UploadEntriesRequestBody struct {
|
||||||
Dest string `query:"dest"`
|
Dest string `query:"dest"`
|
||||||
|
sleepIntervalSec int `query:"interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HarFetchRequestBody struct {
|
type HarFetchRequestBody struct {
|
||||||
|
@@ -112,13 +112,13 @@ func GetAnalyzeInfo() *shared.AnalyzeStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadEntriesImpl(token string, model string, envPrefix string) {
|
func UploadEntriesImpl(token string, model string, envPrefix string, sleepIntervalSec int) {
|
||||||
analyzeInformation.IsAnalyzing = true
|
analyzeInformation.IsAnalyzing = true
|
||||||
analyzeInformation.AnalyzedModel = model
|
analyzeInformation.AnalyzedModel = model
|
||||||
analyzeInformation.AnalyzeToken = token
|
analyzeInformation.AnalyzeToken = token
|
||||||
analyzeInformation.AnalyzeDestination = envPrefix
|
analyzeInformation.AnalyzeDestination = envPrefix
|
||||||
|
|
||||||
sleepTime := time.Second * 10
|
sleepTime := time.Second * time.Duration(sleepIntervalSec)
|
||||||
|
|
||||||
var timestampFrom int64 = 0
|
var timestampFrom int64 = 0
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ type MizuTapOptions struct {
|
|||||||
MizuImage string
|
MizuImage string
|
||||||
PlainTextFilterRegexes []string
|
PlainTextFilterRegexes []string
|
||||||
TapOutgoing bool
|
TapOutgoing bool
|
||||||
|
SleepIntervalSec uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
var mizuTapOptions = &MizuTapOptions{}
|
var mizuTapOptions = &MizuTapOptions{}
|
||||||
@@ -64,6 +65,7 @@ func init() {
|
|||||||
tapCmd.Flags().StringVarP(&mizuTapOptions.Namespace, "namespace", "n", "", "Namespace selector")
|
tapCmd.Flags().StringVarP(&mizuTapOptions.Namespace, "namespace", "n", "", "Namespace selector")
|
||||||
tapCmd.Flags().BoolVar(&mizuTapOptions.Analyze, "analyze", false, "Uploads traffic to UP9 for further analysis (Beta)")
|
tapCmd.Flags().BoolVar(&mizuTapOptions.Analyze, "analyze", false, "Uploads traffic to UP9 for further analysis (Beta)")
|
||||||
tapCmd.Flags().StringVar(&mizuTapOptions.AnalyzeDestination, "dest", "up9.app", "Destination environment")
|
tapCmd.Flags().StringVar(&mizuTapOptions.AnalyzeDestination, "dest", "up9.app", "Destination environment")
|
||||||
|
tapCmd.Flags().Uint16VarP(&mizuTapOptions.SleepIntervalSec, "upload-interval", "", 10, "Interval in seconds for uploading data to UP9")
|
||||||
tapCmd.Flags().BoolVarP(&mizuTapOptions.AllNamespaces, "all-namespaces", "A", false, "Tap all namespaces")
|
tapCmd.Flags().BoolVarP(&mizuTapOptions.AllNamespaces, "all-namespaces", "A", false, "Tap all namespaces")
|
||||||
tapCmd.Flags().StringVarP(&mizuTapOptions.KubeConfigPath, "kube-config", "k", "", "Path to kube-config file")
|
tapCmd.Flags().StringVarP(&mizuTapOptions.KubeConfigPath, "kube-config", "k", "", "Path to kube-config file")
|
||||||
tapCmd.Flags().StringVarP(&mizuTapOptions.MizuImage, "mizu-image", "", fmt.Sprintf("gcr.io/up9-docker-hub/mizu/%s:latest", mizu.Branch), "Custom image for mizu collector")
|
tapCmd.Flags().StringVarP(&mizuTapOptions.MizuImage, "mizu-image", "", fmt.Sprintf("gcr.io/up9-docker-hub/mizu/%s:latest", mizu.Branch), "Custom image for mizu collector")
|
||||||
|
@@ -253,7 +253,7 @@ func portForwardApiPod(ctx context.Context, kubernetesProvider *kubernetes.Provi
|
|||||||
|
|
||||||
time.Sleep(time.Second * 5) // Waiting to be sure the proxy is ready
|
time.Sleep(time.Second * 5) // Waiting to be sure the proxy is ready
|
||||||
if tappingOptions.Analyze {
|
if tappingOptions.Analyze {
|
||||||
url_path := fmt.Sprintf("http://%s/api/uploadEntries?dest=%s", mizuProxiedUrl, url.QueryEscape(tappingOptions.AnalyzeDestination))
|
url_path := fmt.Sprintf("http://%s/api/uploadEntries?dest=%s&interval=%s", mizuProxiedUrl, url.QueryEscape(tappingOptions.AnalyzeDestination), tappingOptions.SleepIntervalSec)
|
||||||
u, err := url.ParseRequestURI(url_path)
|
u, err := url.ParseRequestURI(url_path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(fmt.Sprintf("Failed parsing the URL %v\n", err))
|
log.Fatal(fmt.Sprintf("Failed parsing the URL %v\n", err))
|
||||||
|
Reference in New Issue
Block a user