示例#1
0
func ReportDnsRequestRrnames(appContext AppContext, r *http.Request) interface{} {

	options := core.ReportOptions{}

	if r.Method == http.MethodPost {
		var requestBody struct {
			TimeRange   string `json:"timeRange"`
			Size        int64  `json:"size"`
			QueryString string `json:"queryString"`
		}
		DecodeRequestBody(r, &requestBody)
		options.TimeRange = requestBody.TimeRange
		options.Size = requestBody.Size
		options.QueryString = requestBody.QueryString
	} else {
		options.TimeRange = r.FormValue("timeRange")
		options.Size, _ = strconv.ParseInt(r.FormValue("size"), 10, 64)
		options.QueryString = r.FormValue("queryString")
	}

	data, err := appContext.ReportService.ReportDnsRequestRrnames(options)
	if err != nil {
		return err
	}

	return map[string]interface{}{
		"data": data,
	}

}
示例#2
0
func ReportHistogram(appContext AppContext, r *http.Request) interface{} {
	options := core.ReportOptions{}

	options.TimeRange = r.FormValue("timeRange")
	options.AddressFilter = r.FormValue("addressFilter")
	options.QueryString = r.FormValue("queryString")
	options.SensorFilter = r.FormValue("sensorFilter")
	options.EventType = r.FormValue("eventType")
	options.DnsType = r.FormValue("dnsType")

	interval := r.FormValue("interval")

	response, err := appContext.ReportService.ReportHistogram(interval, options)
	if err != nil {
		return err
	}
	return response
}
示例#3
0
func ReportAggs(appContext AppContext, r *http.Request) interface{} {
	options := core.ReportOptions{}

	agg := r.FormValue("agg")
	options.TimeRange = r.FormValue("timeRange")
	options.Size, _ = strconv.ParseInt(r.FormValue("size"), 10, 64)
	options.AddressFilter = r.FormValue("addressFilter")
	options.QueryString = r.FormValue("queryString")

	options.EventType = r.FormValue("eventType")

	options.DnsType = r.FormValue("dnsType")

	response, err := appContext.ReportService.ReportAggs(agg, options)
	if err != nil {
		return err
	}
	return response
}