Key metrics and engagement data
Repository has been active for N/A
Looks like this repository is a hidden gem!
No stargazers yet. Why not be the first to give it a star?
Check back soon, we will update it in background!
⭐0
Want deeper insights? Explore GitObs.com
A native Go library to streamline and supercharge your interactions with the AWS CloudWatch Logs Insights service using minimalist, native Go, paradigms.
Incite makes it easier to write code to query your logs using AWS CloudWatch Logs Insights, and makes it possible to use Insights to query massive, arbitrary, amounts of log data reliably.
Chunk
field in
QuerySpec
to enable chunking.SplitUntil
field in QuerySpec
to enable dynamic splitting.encoding/json
. (And it
supportsjson:"..."
tags as well as its native incite:"..."
tags, right
out of the box!)time.Time
.1$ go get github.com/gogama/incite
Query
function.QueryManager
using
NewQueryManager
and query it using its Query
method.ReadAll
function.Unmarshal
function.go1package main23import (4 "context"5 "fmt"6 "time"78 "github.com/aws/aws-sdk-go-v2/config"9 "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"10 "github.com/gogama/incite/v2"11)1213func main() {14 // Use the AWS SDK for Go V2 to get the CloudWatch API actions Incite needs.15 // For simplicity, we assume that the correct AWS region and credentials are16 // already set in the environment.1718 cfg, err := config.LoadDefaultConfig(context.TODO())19 if err != nil {20 return21 }22 a := cloudwatchlogs.NewFromConfig(cfg)2324 // Create a QueryManager. An alternative to using a QueryManager is just25 // using the global scope Query function.26 m := incite.NewQueryManager(incite.Config{Actions: a})27 defer func() {28 _ = m.Close()29 }()3031 // Look at the last 15 minutes.32 end := time.Now().Truncate(time.Millisecond)33 start := end.Add(-15*time.Minute)3435 // Query the results.36 s, err := m.Query(incite.QuerySpec{37 Text: "fields @timestamp, @message | filter @message =~ /foo/ | sort @timestamp desc",38 Start: start,39 End: end,40 Groups: []string{"/my/log/group"},41 Limit: 100,42 })43 if err != nil {44 return45 }46 data, err := incite.ReadAll(s)47 if err != nil {48 return49 }5051 // Unpack the results into a structured format.52 var v []struct{53 Timestamp time.Time `incite:"@timestamp"`54 Message string `incite:"@message"`55 }56 err = incite.Unmarshal(data, &v)57 if err != nil {58 return59 }6061 // Print the results!62 fmt.Println(v)63}
Works with all Go versions 1.22 and up, and AWS SDK for Go V2 versions 1.36.5 and up.
Official AWS documentation: Analyzing log data with CloudWatch Logs Insights.
Find Insights' query syntax documentation here
and the API reference here (look
for StartQuery
, GetQueryResults
, and StopQuery
).
This project is licensed under the terms of the MIT License.
Developer happiness on this project was embiggened by JetBrains, which generously donated an open source license for their lovely GoLand IDE. Thanks JetBrains!