Compare commits

...

4 Commits
0.4.6 ... 0.4.9

Author SHA1 Message Date
RamiBerm
672accba0c fix null source in mizu fetch
fix null source in mizu fetch
2021-07-06 13:55:26 +03:00
RamiBerm
566eab3527 Update entries_controller.go and models.go 2021-07-06 13:47:15 +03:00
Alon Girmonsky
0f52533cd8 Update README.md (#82) 2021-07-06 13:21:58 +03:00
gadotroee
eef58496b5 Add source and destination info when fetching entries (x-mizu-fields) (#93) 2021-07-05 17:12:48 +03:00
4 changed files with 17 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
# 水 mizu
standalone web app traffic viewer for Kubernetes
A simple-yet-powerful API traffic viewer for Kubernetes to help you troubleshoot and debug your microservices. Think TCPDump and Chrome Dev Tools combined.
## Download
@@ -29,7 +29,7 @@ Pick one from the [Releases](https://github.com/up9inc/mizu/releases) page.
## How to run
1. Find pod you'd like to tap to in your Kubernetes cluster
2. Run `mizu PODNAME` or `mizu REGEX`
2. Run `mizu tap PODNAME` or `mizu tap REGEX`
3. Open browser on `http://localhost:8899` as instructed ..
4. Watch the WebAPI traffic flowing ..
5. Type ^C to stop

View File

@@ -93,13 +93,16 @@ func GetHARs(c *fiber.Ctx) error {
harEntry.Request.URL = utils.SetHostname(harEntry.Request.URL, entryData.ResolvedDestination)
}
var fileName string
sourceOfEntry := entryData.ResolvedSource
if sourceOfEntry != "" {
// naively assumes the proper service source is http
sourceOfEntry = fmt.Sprintf("http://%s", sourceOfEntry)
//replace / from the file name cause they end up creating a corrupted folder
fileName = fmt.Sprintf("%s.har", strings.ReplaceAll(sourceOfEntry, "/", "_"))
} else {
fileName = "unknown_source.har"
}
//replace / from the file name cause they end up creating a corrupted folder
fileName := fmt.Sprintf("%s.har", strings.ReplaceAll(sourceOfEntry, "/", "_"))
if harOfSource, ok := harsObject[fileName]; ok {
harOfSource.Log.Entries = append(harOfSource.Log.Entries, &harEntry)
} else {
@@ -119,7 +122,7 @@ func GetHARs(c *fiber.Ctx) error {
}
// leave undefined when no source is present, otherwise modeler assumes source is empty string ""
if sourceOfEntry != "" {
harsObject[fileName].Log.Creator.Source = sourceOfEntry
harsObject[fileName].Log.Creator.Source = &sourceOfEntry
}
}
}

View File

@@ -63,6 +63,14 @@ func GetEntriesFromDb(timestampFrom int64, timestampTo int64) []har.Entry {
for _, entryData := range entries {
var harEntry har.Entry
_ = json.Unmarshal([]byte(entryData.Entry), &harEntry)
if entryData.ResolvedSource != "" {
harEntry.Request.Headers = append(harEntry.Request.Headers, har.Header{Name: "x-mizu-source", Value: entryData.ResolvedSource})
}
if entryData.ResolvedDestination != "" {
harEntry.Request.Headers = append(harEntry.Request.Headers, har.Header{Name: "x-mizu-destination", Value: entryData.ResolvedDestination})
}
entriesArray = append(entriesArray, harEntry)
}
return entriesArray

View File

@@ -105,5 +105,5 @@ type ExtendedLog struct {
type ExtendedCreator struct {
*har.Creator
Source string `json:"_source"`
Source *string `json:"_source"`
}