The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/export/export_live.go

50 lines
1.1 KiB

package export
import (
"fmt"
"path"
"time"
"github.com/grafana/grafana/pkg/infra/db"
)
func exportLive(helper *commitHelper, job *gitExportJob) error {
messagedir := path.Join(helper.orgDir, "system", "live", "message")
return job.sql.WithDbSession(helper.ctx, func(sess *db.Session) error {
type msgResult struct {
Channel string `xorm:"channel"`
Data string `xorm:"data"`
CreatedBy int64 `xorm:"created_by"`
Created time.Time `xorm:"created"`
}
rows := make([]*msgResult, 0)
sess.Table("live_message").Where("org_id = ?", helper.orgID)
err := sess.Find(&rows)
if err != nil {
if isTableNotExistsError(err) {
return nil
}
return err
}
for _, row := range rows {
err = helper.add(commitOptions{
body: []commitBody{{
body: []byte(row.Data),
fpath: path.Join(messagedir, row.Channel) + ".json", // must be JSON files
}},
comment: fmt.Sprintf("Exporting: %s", row.Channel),
when: row.Created,
userID: row.CreatedBy,
})
if err != nil {
return err
}
}
return err
})
}