Created
March 13, 2018 11:48
-
-
Save gouthamve/7ee40d6ab5b7fb0fa0a9282ababf561e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io/ioutil" | |
"os" | |
"time" | |
"github.com/go-kit/kit/log" | |
"github.com/prometheus/tsdb" | |
"github.com/prometheus/tsdb/labels" | |
) | |
func main() { | |
tmpdir, err := ioutil.TempDir("", "test") | |
defer os.RemoveAll(tmpdir) | |
rngs := tsdb.ExponentialBlockRanges(2*60*60*1000, 10, 3) | |
db, err := tsdb.Open(tmpdir, log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr)), nil, &tsdb.Options{ | |
WALFlushInterval: 5 * time.Second, | |
RetentionDuration: 999999 * 24 * 60 * 60 * 1000, | |
BlockRanges: rngs, | |
}) | |
checkErr(err) | |
for t := int64(1518912000000); t < 1520856000000; t += 10000 { | |
app := db.Appender() | |
app.Add(labels.Labels{labels.Label{"as", "bs"}}, t, 0) | |
checkErr(app.Commit()) | |
time.Sleep(1 * time.Millisecond) | |
} | |
} | |
func checkErr(err error) { | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment