- Go 1.22 or later
- Scheduled binary execution service (e.g., cron, AWS Lambda, Google Cloud Run)
Write your own main.go. For example, the following code collects logs from Slack and stores them in Google Cloud Storage.
package main
import (
"os"
"github.com/secmon-lab/hatchery"
"github.com/secmon-lab/hatchery/destination/gcs"
"github.com/secmon-lab/hatchery/pkg/types/secret"
"github.com/secmon-lab/hatchery/source/slack"
)
func main() {
streams := []*hatchery.Stream{
hatchery.NewStream(
// Source: Slack Audit API
slack.New(secret.NewString(os.Getenv("SLACK_TOKEN"))),
// Destination: Google Cloud Storage, bucket name is "mizutani-test"
gcs.New("mizutani-test"),
// Option: WithID sets the stream ID
hatchery.WithID("slack-to-gcs"),
),
}
// You can run CLI with args such as `go run main.go -i slack-to-gcs`
if err := hatchery.New(streams).CLI(os.Args); err != nil {
panic(err)
}
}Build your binary.
$ go build -o myhatchery main.goRun your binary.
$ env SLACK_TOKEN=your-slack-token ./myhatchery -s slack-to-gcsIt will collect logs from Slack and store them in Google Cloud Storage.