We are using CSV to get the analytics from Tyk. It works fine for us.
Tyk-pump creates one CSV file every hour or at least that’s what I can infer. Is there a way to config tyk pump to output to one file only?
Is there a way to config tyk-pump to create new file when a certain size exceeds say 10MB?
Is there a way to config the CSV file name format?
Martin
April 18, 2017, 4:16am
2
I’m sorry to say that there’s no other settings except for the CSV directory to use, if you want to add these features you’ll need to modify the CSV pump
In particular, you can change the filename to be fixed instead of dynamic by changing this line:
c.log.Fatal("Failed to decode configuration: ", err)
}
processPumpEnvVars(c, c.log, c.csvConf, csvDefaultENV)
ferr := os.MkdirAll(c.csvConf.CSVDir, 0777)
if ferr != nil {
c.log.Error(ferr.Error() + " dir: " + c.csvConf.CSVDir)
}
c.log.Info(c.GetName() + " Initialized")
return nil
}
func (c *CSVPump) WriteData(ctx context.Context, data []interface{}) error {
c.log.Debug("Attempting to write ", len(data), " records...")
curtime := time.Now()
fname := fmt.Sprintf("%d-%s-%d-%d.csv", curtime.Year(), curtime.Month().String(), curtime.Day(), curtime.Hour())
fname = path.Join(c.csvConf.CSVDir, fname)
You could also add the file-size check to the pump there after it stats it