Skip to content

Commit

Permalink
Adding in ult exit data when present (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
i3149 authored Oct 11, 2024
1 parent 423fdd9 commit 5118678
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/ktranslate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func init() {
flag.IntVar(&threads, "threads", 1, "Number of threads to run for processing")
flag.IntVar(&threadsInput, "input_threads", 1, "Number of threads to run for input processing")
flag.IntVar(&maxThreads, "max_threads", 1, "Dynamically grow threads up to this number")
flag.StringVar(&format, "format", "flat_json", "Format to convert kflow to: (json|flat_json|avro|netflow|influx|carbon|prometheus|new_relic|new_relic_metric|splunk|elasticsearch|kflow|ddog)")
flag.StringVar(&format, "format", "flat_json", "Format to convert kflow to: (json|flat_json|avro|netflow|influx|carbon|prometheus|new_relic|new_relic_metric|splunk|elasticsearch|kflow|ddog|otel|snmp|parquet)")
flag.StringVar(&formatRollup, "format_rollup", "", "Format to convert rollups to: (json|avro|netflow|influx|prometheus|new_relic|new_relic_metric|splunk|elasticsearch|kflow|parquet)")
flag.StringVar(&formatMetric, "format_metric", "", "Format to convert metrics to: (json|avro|netflow|influx|prometheus|new_relic|new_relic_metric|splunk|elasticsearch|kflow|parquet)")
flag.StringVar(&compression, "compression", "none", "compression algo to use (none|gzip|snappy|deflate|null)")
Expand Down
14 changes: 14 additions & 0 deletions pkg/cat/jchf.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (kc *KTranslate) flowToJCHF(ctx context.Context, dst *kt.JCHF, src *Flow, c
dst.CustomInt[name] = int32(v)
if d := kc.apic.GetDevice(dst.CompanyId, kt.DeviceID(v)); d != nil {
dst.CustomStr["ult_exit_device"] = d.Name
dst.CustomStr["ult_device_site"] = d.Site.SiteName
}
default:
if tk, tv, ok := kc.tagMap.LookupTagValue(dst.CompanyId, v, name); ok {
Expand Down Expand Up @@ -387,6 +388,19 @@ func (kc *KTranslate) flowToJCHF(ctx context.Context, dst *kt.JCHF, src *Flow, c
}
}

// Check if there is ultimate exit data interface and pull this in also.
if udid, ok := dst.CustomInt["ult_exit_device_id"]; ok {
if d := kc.apic.GetDevice(dst.CompanyId, kt.DeviceID(udid)); d != nil {
if ui, ok := dst.CustomInt["ult_exit_port"]; ok {
if i, ok := d.Interfaces[kt.IfaceID(ui)]; ok {
dst.CustomStr["ult_exit_port_alias"] = i.Alias
dst.CustomStr["ult_exit_port_description"] = i.Description
dst.CustomStr["ult_exit_port_provider"] = i.Provider
}
}
}
}

// Do we need to remap any of the custom strings?
for k, v := range dst.CustomStr {
switch dst.CustomStr[UDR_TYPE] { // Kick out any cross contaminated tags.
Expand Down

0 comments on commit 5118678

Please sign in to comment.