Skip to content

Commit

Permalink
Added - user.name data to manictime beat
Browse files Browse the repository at this point in the history
  • Loading branch information
benedery committed Aug 11, 2020
1 parent 9ccacf0 commit 8a3ec73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metricbeat/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

make collect
make
go build -o metricbeat_0.0.10 main.go
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o metricbeat_0.0.10.exe main.go
go build -o metricbeat_0.0.11 main.go
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o metricbeat_0.0.11.exe main.go
12 changes: 12 additions & 0 deletions metricbeat/module/system/manictime/manictime.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
"os/user"
"path/filepath"
"strings"
"time"
Expand All @@ -31,6 +32,7 @@ func init() {
type MetricSet struct {
mb.BaseMetricSet
database *sql.DB
userName string
}

type ManicTimeConfig struct {
Expand Down Expand Up @@ -88,12 +90,18 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
fmt.Println("could not open db file of manicTime")
}

user, err := user.Current()
if err != nil {
fmt.Println("could not get user details", err)
}

// // get last updated time
// lastSync = getLastSyncTime(database)

return &MetricSet{
BaseMetricSet: base,
database: database,
userName: user.Username,
}, nil
}

Expand Down Expand Up @@ -122,11 +130,15 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) error {
"durationMin": activity.durationMin,
"durationSec": activity.durationSec,
"applicationName": activity.applicationName,
"id": activity.id,
}
report.Event(mb.Event{
MetricSetFields: common.MapStr{
"data": rootFields,
},
RootFields: common.MapStr{
"user.name": m.userName,
},
})
}

Expand Down

0 comments on commit 8a3ec73

Please sign in to comment.