Skip to content

Commit

Permalink
fixing tsdb lables support
Browse files Browse the repository at this point in the history
  • Loading branch information
aviaIguazio committed Jul 18, 2018
1 parent ca2ca44 commit 936af72
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/csv_2_tsdb_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ title = "Workload example"

[global]
Duration = "160s"
server="localhost"
server="192.168.206.22"
port="44001"
TLSMode=false
[global.StatusCodesAcceptance]
Expand Down
2 changes: 1 addition & 1 deletion examples/schemas/tsdb_schema_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"TSDBTime": "Time_Sequence",
"TSDBName" : "Broker_ID",
"TSDBValue" : "Total_Orders",
"TSDBAttributes" : "Status_Flag,Active_Status"
"TSDBLables" : "Status_Flag,Active_Status"
},
"COLUMNS": [
{
Expand Down
8 changes: 8 additions & 0 deletions httpblaster/http_blaster_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package httpblaster
/*
import (
"testing"
"io/ioutil"
"path"
)
import (
"bytes"
Expand Down Expand Up @@ -204,3 +211,4 @@ func Test_PUT_Multi_Worker(t *testing.T) {
}
t.Logf("total number of requests %d", uint64(count)*wl.req_count)
}
*/
21 changes: 14 additions & 7 deletions httpblaster/igz_data/igz_tsdb_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type IgzTSDBItem struct {
}

func (self *IgzTSDBItem) GenerateStruct(vals []string,parser *EmdSchemaParser){
self.InsertTSDBName(parser.tsdb_attributes_map,vals,T_STRING,vals[parser.tsdb_name_index])
//self.InsertTSDBName(parser.tsdb_attributes_map,vals,T_STRING,vals[parser.tsdb_name_index])
self.InsertTSDBName(vals,parser)
self.InsertTime(vals ,parser)
self.InsertValue(vals[parser.tsdb_value_index])
}
Expand All @@ -28,12 +29,18 @@ func (self *IgzTSDBItem) ToJsonString() string {
return string(body)
}

func (self *IgzTSDBItem) InsertTSDBName(attributes_map map[string]int,vals []string,value_type IgzType, value interface{}) error {

strVal := value.(string)

self.Lset = utils.Labels{{Name: "__name__",Value:strVal}}
for key, val := range attributes_map {
//func (self *IgzTSDBItem) InsertTSDBName(attributes_map map[string]int,vals []string,value_type IgzType, value interface{}) error {
func (self *IgzTSDBItem) InsertTSDBName(vals []string,parser *EmdSchemaParser) error {
for i, v := range parser.values_map {
if v.Name == parser.tsdb_time {
parser.tsdb_time_index = i
}
}
input := vals[parser.tsdb_name_index]
//add validation on time
self.Time= input
self.Lset = utils.Labels{{Name: "__name__",Value:input}}
for key, val := range parser.tsdb_attributes_map {
lable := utils.Label{Name: key, Value: vals[val]}
self.Lset= append(self.Lset,lable)
}
Expand Down
29 changes: 28 additions & 1 deletion httpblaster/schema_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import (
"testing"
//"go/parser"
"strings"
)


"github.com/v3io/v3io-tsdb/pkg/utils"
"encoding/json"
"fmt"
)




Expand Down Expand Up @@ -90,3 +94,26 @@ func Test_tsdb_Schema_Parser(t *testing.T) {

}

func Test_tsdb_to_json(t *testing.T) {
item := igz_data.IgzTSDBItem{}
item.Lset = utils.Labels{{Name: "__name__", Value: "name"}}
item.Time = "1529659800000"
item.Value = 1
item2 := igz_data.IgzTSDBItem{}
item2.Lset = utils.Labels{{Name: "__name__", Value: "name2"}}
item2.Time = "1529659900000"
item2.Value = 2

items := []igz_data.IgzTSDBItem{item, item2}
body, _ := json.Marshal(items)
fmt.Println(string(body))
}









0 comments on commit 936af72

Please sign in to comment.