Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed bucket #19

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions cmd/log2sql/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ build:
# Note that this will download and build the latest version of package from github - it won't build the local go
# repo. So you need to have published everything (and ensure tags are as desired) before doing this.
dist:
~/go/bin/xgo -go latest --targets=windows/amd64,darwin/amd64 ${LDFLAGS} github.com/rcowham/go-libp4dlog/cmd/log2sql
~/go/bin/xgo -go latest --targets=linux/amd64 ${LINUX_LDFLAGS} github.com/rcowham/go-libp4dlog/cmd/log2sql
~/go/bin/xgo -go latest --targets=windows/amd64,darwin/amd64 ${LDFLAGS} github.com/RishiMunagala/go-libp4dlog/cmd/log2sql
~/go/bin/xgo -go latest --targets=linux/amd64 ${LINUX_LDFLAGS} github.com/RishiMunagalago-libp4dlog/cmd/log2sql
rm -f log2sql*amd64*.gz
-chmod +x log2sql*amd64*
gzip log2sql*amd64*
Expand Down
4 changes: 2 additions & 2 deletions cmd/log2sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
// "github.com/pkg/profile"

"github.com/perforce/p4prometheus/version"
p4dlog "github.com/rcowham/go-libp4dlog"
"github.com/rcowham/go-libp4dlog/metrics"
p4dlog "github.com/RishiMunagala/go-libp4dlog"
"github.com/RishiMunagala/go-libp4dlog/metrics"
)

const statementsPerTransaction = 50 * 1000
Expand Down
2 changes: 1 addition & 1 deletion cmd/p4dpending/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build:
# Note that this will download and build the latest version of package from github - it won't build the local go
# repo. So you need to have published everything (and ensure tags are as desired) before doing this.
dist:
~/go/bin/xgo --targets=linux/amd64,windows/amd64,darwin/amd64 ${LDFLAGS} github.com/rcowham/go-libp4dlog/cmd/p4dpending
~/go/bin/xgo --targets=linux/amd64,windows/amd64,darwin/amd64 ${LDFLAGS} github.com/RishiMunagala/go-libp4dlog/cmd/p4dpending
rm -f p4dpending*amd64*.gz
-chmod +x p4dpending*amd64*
gzip p4dpending*amd64*
Expand Down
2 changes: 1 addition & 1 deletion cmd/p4dpending/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// "github.com/pkg/profile"

"github.com/perforce/p4prometheus/version"
p4dlog "github.com/rcowham/go-libp4dlog"
p4dlog "github.com/RishiMunagala/go-libp4dlog"
)

func dateStr(t time.Time) string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/p4locks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// "github.com/pkg/profile"

"github.com/perforce/p4prometheus/version"
p4dlog "github.com/rcowham/go-libp4dlog"
p4dlog "github.com/RishiMunagala/go-libp4dlog"
)

// Threshold in milliseconds below which we filter out commands - for at least one of read/write wait/held
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/rcowham/go-libp4dlog
module github.com/RishiMunagala/go-libp4dlog

go 1.18

Expand Down
68 changes: 41 additions & 27 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"strings"
"time"

p4dlog "github.com/rcowham/go-libp4dlog"
p4dlog "github.com/RishiMunagala/go-libp4dlog"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -180,6 +180,19 @@ func (p4m *P4DMetrics) printMetric(metrics *bytes.Buffer, mname string, labels [
fmt.Fprint(metrics, buf)
}

func (p4m *P4DMetrics) resetToZero() {
//for _, t := range cmd.Tables {
//p4m.totalReadHeld[t.TableName] = 0
//p4m.totalReadWait[t.TableName] = 0
//p4m.totalWriteHeld[t.TableName] = 0
//p4m.totalWriteWait[t.TableName] = 0
//}
p4m.syncFilesUpdated = 0
p4m.syncFilesDeleted = 0
p4m.syncBytesAdded = 0
p4m.syncBytesUpdated = 0
}

// Publish cumulative results - called on a ticker or in historical mode
func (p4m *P4DMetrics) getCumulativeMetrics() string {
fixedLabels := []labelStruct{{name: "serverid", value: p4m.config.ServerID},
Expand All @@ -192,7 +205,7 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
var mname string
var metricVal string
mname = "p4_prom_log_lines_read"
p4m.printMetricHeader(metrics, mname, "A count of log lines read", "counter")
p4m.printMetricHeader(metrics, mname, "A count of log lines read", "gauge")
metricVal = fmt.Sprintf("%d", p4m.linesRead)
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

Expand Down Expand Up @@ -224,60 +237,60 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

mname = "p4_sync_files_added"
p4m.printMetricHeader(metrics, mname, "The number of files added to workspaces by syncs", "counter")
p4m.printMetricHeader(metrics, mname, "The number of files added to workspaces by syncs", "gauge")
metricVal = fmt.Sprintf("%d", p4m.syncFilesAdded)
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

mname = "p4_sync_files_updated"
p4m.printMetricHeader(metrics, mname, "The number of files updated in workspaces by syncs", "counter")
p4m.printMetricHeader(metrics, mname, "The number of files updated in workspaces by syncs", "gauge")
metricVal = fmt.Sprintf("%d", p4m.syncFilesUpdated)
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

mname = "p4_sync_files_deleted"
p4m.printMetricHeader(metrics, mname, "The number of files deleted in workspaces by syncs", "counter")
p4m.printMetricHeader(metrics, mname, "The number of files deleted in workspaces by syncs", "gauge")
metricVal = fmt.Sprintf("%d", p4m.syncFilesDeleted)
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

mname = "p4_sync_bytes_added"
p4m.printMetricHeader(metrics, mname, "The number of bytes added to workspaces by syncs", "counter")
p4m.printMetricHeader(metrics, mname, "The number of bytes added to workspaces by syncs", "gauge")
metricVal = fmt.Sprintf("%d", p4m.syncBytesAdded)
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

mname = "p4_sync_bytes_updated"
p4m.printMetricHeader(metrics, mname, "The number of bytes updated in workspaces by syncs", "counter")
p4m.printMetricHeader(metrics, mname, "The number of bytes updated in workspaces by syncs", "gauge")
metricVal = fmt.Sprintf("%d", p4m.syncBytesUpdated)
p4m.printMetric(metrics, mname, fixedLabels, metricVal)

mname = "p4_cmd_counter"
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by cmd)", "gauge")
for cmd, count := range p4m.cmdCounter {
metricVal = fmt.Sprintf("%d", count)
labels := append(fixedLabels, labelStruct{"cmd", cmd})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in seconds (by cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in seconds (by cmd)", "gauge")
for cmd, lapse := range p4m.cmdCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"cmd", cmd})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_cpu_user_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in user CPU seconds (by cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in user CPU seconds (by cmd)", "gauge")
for cmd, lapse := range p4m.cmduCPUCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"cmd", cmd})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_cpu_system_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in system CPU seconds (by cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in system CPU seconds (by cmd)", "gauge")
for cmd, lapse := range p4m.cmdsCPUCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"cmd", cmd})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_error_counter"
p4m.printMetricHeader(metrics, mname, "A count of cmd errors (by cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of cmd errors (by cmd)", "gauge")
for cmd, count := range p4m.cmdErrorCounter {
metricVal = fmt.Sprintf("%d", count)
labels := append(fixedLabels, labelStruct{"cmd", cmd})
Expand All @@ -286,14 +299,14 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
// For large sites this might not be sensible - so they can turn it off
if p4m.config.OutputCmdsByUser {
mname = "p4_cmd_user_counter"
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by user)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by user)", "gauge")
for user, count := range p4m.cmdByUserCounter {
metricVal = fmt.Sprintf("%d", count)
labels := append(fixedLabels, labelStruct{"user", user})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_user_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in seconds (by user)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in seconds (by user)", "gauge")
for user, lapse := range p4m.cmdByUserCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"user", user})
Expand All @@ -303,14 +316,14 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
// For large sites this might not be sensible - so they can turn it off
if p4m.config.OutputCmdsByIP {
mname = "p4_cmd_ip_counter"
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by IP)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by IP)", "gauge")
for ip, count := range p4m.cmdByIPCounter {
metricVal = fmt.Sprintf("%d", count)
labels := append(fixedLabels, labelStruct{"ip", ip})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_ip_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in seconds (by IP)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in seconds (by IP)", "gauge")
for ip, lapse := range p4m.cmdByIPCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"ip", ip})
Expand All @@ -320,7 +333,7 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
// For large sites this might not be sensible - so they can turn it off
if p4m.config.OutputCmdsByUserRegex != "" {
mname = "p4_cmd_user_detail_counter"
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by user and cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by user and cmd)", "gauge")
for user, userMap := range p4m.cmdByUserDetailCounter {
for cmd, count := range userMap {
metricVal = fmt.Sprintf("%d", count)
Expand All @@ -330,7 +343,7 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
}
}
mname = "p4_cmd_user_detail_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in seconds (by user and cmd)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in seconds (by user and cmd)", "gauge")
for user, userMap := range p4m.cmdByUserDetailCumulative {
for cmd, lapse := range userMap {
metricVal = fmt.Sprintf("%0.3f", lapse)
Expand All @@ -341,60 +354,60 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
}
}
mname = "p4_cmd_replica_counter"
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by broker/replica/proxy)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by broker/replica/proxy)", "gauge")
for replica, count := range p4m.cmdByReplicaCounter {
metricVal = fmt.Sprintf("%d", count)
labels := append(fixedLabels, labelStruct{"replica", replica})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_replica_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in seconds (by broker/replica/proxy)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in seconds (by broker/replica/proxy)", "gauge")
for replica, lapse := range p4m.cmdByReplicaCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"replica", replica})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_program_counter"
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by program)", "counter")
p4m.printMetricHeader(metrics, mname, "A count of completed p4 cmds (by program)", "gauge")
for program, count := range p4m.cmdByProgramCounter {
metricVal = fmt.Sprintf("%d", count)
labels := append(fixedLabels, labelStruct{"program", program})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_cmd_program_cumulative_seconds"
p4m.printMetricHeader(metrics, mname, "The total in seconds (by program)", "counter")
p4m.printMetricHeader(metrics, mname, "The total in seconds (by program)", "gauge")
for program, lapse := range p4m.cmdByProgramCumulative {
metricVal = fmt.Sprintf("%0.3f", lapse)
labels := append(fixedLabels, labelStruct{"program", program})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_total_read_wait_seconds"
p4m.printMetricHeader(metrics, mname,
"The total waiting for read locks in seconds (by table)", "counter")
"The total waiting for read locks in seconds (by table)", "gauge")
for table, total := range p4m.totalReadWait {
metricVal = fmt.Sprintf("%0.3f", total)
labels := append(fixedLabels, labelStruct{"table", table})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_total_read_held_seconds"
p4m.printMetricHeader(metrics, mname,
"The total read locks held in seconds (by table)", "counter")
"The total read locks held in seconds (by table)", "gauge")
for table, total := range p4m.totalReadHeld {
metricVal = fmt.Sprintf("%0.3f", total)
labels := append(fixedLabels, labelStruct{"table", table})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_total_write_wait_seconds"
p4m.printMetricHeader(metrics, mname,
"The total waiting for write locks in seconds (by table)", "counter")
"The total waiting for write locks in seconds (by table)", "gauge")
for table, total := range p4m.totalWriteWait {
metricVal = fmt.Sprintf("%0.3f", total)
labels := append(fixedLabels, labelStruct{"table", table})
p4m.printMetric(metrics, mname, labels, metricVal)
}
mname = "p4_total_write_held_seconds"
p4m.printMetricHeader(metrics, mname,
"The total write locks held in seconds (by table)", "counter")
"The total write locks held in seconds (by table)", "gauge")
for table, total := range p4m.totalWriteHeld {
metricVal = fmt.Sprintf("%0.3f", total)
labels := append(fixedLabels, labelStruct{"table", table})
Expand All @@ -403,7 +416,7 @@ func (p4m *P4DMetrics) getCumulativeMetrics() string {
if len(p4m.totalTriggerLapse) > 0 {
mname = "p4_total_trigger_lapse_seconds"
p4m.printMetricHeader(metrics, mname,
"The total lapse time for triggers in seconds (by trigger)", "counter")
"The total lapse time for triggers in seconds (by trigger)", "gauge")
for table, total := range p4m.totalTriggerLapse {
metricVal = fmt.Sprintf("%0.3f", total)
labels := append(fixedLabels, labelStruct{"trigger", table})
Expand Down Expand Up @@ -570,6 +583,7 @@ func (p4m *P4DMetrics) ProcessEvents(ctx context.Context, linesInChan <-chan str
}
if !p4m.historical {
metricsChan <- p4m.getCumulativeMetrics()
p4m.resetToZero()
}
case cmd, ok := <-cmdsInChan:
if ok {
Expand Down
9 changes: 9 additions & 0 deletions modifiedPrometheusDetails
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Change repo: "github.com/rcowham/go-libp4dlog" --> "github.com/RishiMunagala/go-libp4dlog"
p4prom.go
go.mod
p4prom_test.go

Added "_bucket" in go-libp4dlog to:
metrics.go
metrics_test.go
p4historical.json