yats.git

commit 61593371ca419750c286a1b0dfa243dc7aa60fc7

Author: Paolo Lulli <paolo@lulli.net>

Update client settings

 .gitignore | 1 +
 client/event-client-rest.go | 6 +++---
 client/main.go | 6 ++++--
 client/metric-client-rest.go | 6 +++---
 client/position-client-test.go | 20 ++++++++++++++++++++
 clients/shell/LogNow.sh | 2 +-


diff --git a/.gitignore b/.gitignore
index 51d3690539324a9ea0345a16c73d872f8ba65cd6..36f3fc893fb1a2c6f5430d07dcf02fb130b23f23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ server/yats-server
 .dqt
 server/.dqt
 .vscode/
+*/nohup.out




diff --git a/client/event-client-rest.go b/client/event-client-rest.go
index b71556506e492caa76486763eb4c650617aed376..b8c4d5c53905a5f6cc89fe16c23930b762f82848 100644
--- a/client/event-client-rest.go
+++ b/client/event-client-rest.go
@@ -5,15 +5,15 @@ 	"fmt"
 	"strconv"
 )
 
-func (c *YatsClient) EventList(from int64, to int64) string {
+func (c *YatsClient) EventList(source string, from int64, to int64) string {
 	if from == 0 {
 		panic("From is empty")
 	}
 	var body string
 	if to == 0 {
-		body = "{ \"from\":" + strconv.FormatInt(from, 10) + " }"
+		body = "{\"source\": \"" + source + "\", \"from\":" + strconv.FormatInt(from, 10) + " }"
 	} else {
-		body = "{ \"from\":" + strconv.FormatInt(from, 10) + ",\"to\":" + strconv.FormatInt(to, 10) + " }"
+		body = "{\"source\": \"" + source + "\", \"from\":" + strconv.FormatInt(from, 10) + ",\"to\":" + strconv.FormatInt(to, 10) + " }"
 	}
 	fmt.Printf("request: [%s]\n", body)
 	return c.ApiPost(c.config.Endpoint+"/event/search", body)




diff --git a/client/main.go b/client/main.go
index d96905b7c9dacab2a015244c7c86ab71d8755614..5c9a543c540224b8208fd6883a2d579f698009d3 100644
--- a/client/main.go
+++ b/client/main.go
@@ -34,6 +34,8 @@
 	cfg := config.GetClientConfig(configPath)
 	var yatsClient = YatsClient{config: cfg}
 
+	sourceOption := flag.StringP("source", "s", "", "Source Application")
+
 	isMetricOption := flag.BoolP("isMetric", "m", false, "Select Metric")
 	fromOption := flag.Int64("from", 0, "From tstamp")
 	toOption := flag.Int64("to", 0, "To tstamp")
@@ -42,10 +44,10 @@
 	flag.Parse()
 
 	if *isMetricOption {
-		listResponse := yatsClient.MetricList(*metricNameOption, *fromOption, *toOption)
+		listResponse := yatsClient.MetricList(*sourceOption, *metricNameOption, *fromOption, *toOption)
 		fmt.Printf("Metric list: %s", listResponse)
 	} else {
-		listEvents := yatsClient.EventList(*fromOption, *toOption)
+		listEvents := yatsClient.EventList(*sourceOption, *fromOption, *toOption)
 		fmt.Printf("Event list: %s", listEvents)
 	}
 




diff --git a/client/metric-client-rest.go b/client/metric-client-rest.go
index d3a4c3e086f5e9cd768ffc3308dc14883a4be7d1..42c4dff04449ca0af7e7d1451e3f2ba6f3f463be 100644
--- a/client/metric-client-rest.go
+++ b/client/metric-client-rest.go
@@ -14,15 +14,15 @@ 	"fmt"
 	"strconv"
 )
 
-func (c *YatsClient) MetricList(metricName string, from int64, to int64) string {
+func (c *YatsClient) MetricList(source string, metricName string, from int64, to int64) string {
 	if metricName == "" {
 		panic("Metric Name is empty")
 	}
 	var body string
 	if to == 0 {
-		body = "{\"name\":\"" + metricName + "\", \"from\":" + strconv.FormatInt(from, 10) + " }"
+		body = "{\"source\": \"" + source + "\", \"name\":\"" + metricName + "\", \"from\":" + strconv.FormatInt(from, 10) + " }"
 	} else {
-		body = "{\"name\":\"" + metricName + "\", \"from\":" + strconv.FormatInt(from, 10) + ",\"to\":" + strconv.FormatInt(to, 10) + " }"
+		body = "{\"source\": \"" + source + "\",\"name\":\"" + metricName + "\", \"from\":" + strconv.FormatInt(from, 10) + ",\"to\":" + strconv.FormatInt(to, 10) + " }"
 	}
 	fmt.Printf("request: [%s]\n", body)
 	return c.ApiPost(c.config.Endpoint+"/metric/search", body)




diff --git a/client/position-client-test.go b/client/position-client-test.go
new file mode 100644
index 0000000000000000000000000000000000000000..b39ab11c7c447f5ed00c488282d46b9c419206bf
--- /dev/null
+++ b/client/position-client-test.go
@@ -0,0 +1,20 @@
+package main
+
+import (
+	"fmt"
+	"strconv"
+)
+
+func (c *YatsClient) PositionList(source string, from int64, to int64) string {
+	if from == 0 {
+		panic("From is empty")
+	}
+	var body string
+	if to == 0 {
+		body = "{\"source\": \"" + source + "\", \"from\":" + strconv.FormatInt(from, 10) + " }"
+	} else {
+		body = "{\"source\": \"" + source + "\", \"from\":" + strconv.FormatInt(from, 10) + ",\"to\":" + strconv.FormatInt(to, 10) + " }"
+	}
+	fmt.Printf("request: [%s]\n", body)
+	return c.ApiPost(c.config.Endpoint+"/position/search", body)
+}




diff --git a/clients/shell/LogNow.sh b/clients/shell/LogNow.sh
index dd046920707b38ca20476a02a9298acff82d1941..8fb209e3038a251ff5b89b9067d029165394573e 100755
--- a/clients/shell/LogNow.sh
+++ b/clients/shell/LogNow.sh
@@ -4,4 +4,4 @@ curl \
 	-X POST\
 	--header "Content-Type: application/json"\
 	-d '{"id_client":"test-cli","name":"test-log","value":"A log message"}'\
-	http://127.0.0.1:18081/rt/metric
+	http://127.0.0.1:18081/metric