Skip to content

Commit

Permalink
Change field type system.process.cpu.start_time from keyword to date (#…
Browse files Browse the repository at this point in the history
…2191)

Fixes #1565
  • Loading branch information
andrewkroh authored and ruflin committed Aug 9, 2016
1 parent 9d547aa commit 21852f6
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha5...master[Check the HEAD d
- Change Elasticsearch output index configuration to be based on format strings. If index has been configured, no date will be appended anymore to the index name. {pull}2119[2119]

*Metricbeat*
- Change field type system.process.cpu.start_time from keyword to date. {issue}1565[1565]

*Packetbeat*

Expand Down
4 changes: 2 additions & 2 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2802,9 +2802,9 @@ The total CPU time spent by the process.
[float]
=== system.process.cpu.start_time

type: keyword
type: date

The time when the process was started. Example: "17:45".
The time when the process was started.


[float]
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/etc/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1681,9 +1681,9 @@
description: >
The total CPU time spent by the process.
- name: start_time
type: keyword
type: date
description: >
The time when the process was started. Example: "17:45".
The time when the process was started.
- name: memory
type: group
description: Memory-specific statistics per process.
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/etc/kibana/index-pattern/metricbeat.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions metricbeat/metricbeat.template-es2x.json
Original file line number Diff line number Diff line change
Expand Up @@ -1760,9 +1760,7 @@
"cpu": {
"properties": {
"start_time": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
"type": "date"
},
"system": {
"type": "long"
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/metricbeat.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -1744,8 +1744,7 @@
"cpu": {
"properties": {
"start_time": {
"ignore_above": 1024,
"type": "keyword"
"type": "date"
},
"system": {
"type": "long"
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/process/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"process": {
"cmdline": "go test -tags=integration github.com/elastic/beats/metricbeat/module/... -data",
"cpu": {
"start_time": "07:16",
"start_time": "2016-08-08T16:39:13.040Z",
"total": {
"pct": 0.01
}
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/system/process/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
description: >
The total CPU time spent by the process.
- name: start_time
type: keyword
type: date
description: >
The time when the process was started. Example: "17:45".
The time when the process was started.
- name: memory
type: group
description: Memory-specific statistics per process.
Expand Down
10 changes: 8 additions & 2 deletions metricbeat/module/system/process/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ func (procStats *ProcStats) GetProcessEvent(process *Process, last *Process) com
"ticks": process.Cpu.Total,
"pct": GetProcCpuPercentage(last, process),
},
"start_time": process.Cpu.FormatStartTime(),
"start_time": unixTimeMsToTime(process.Cpu.StartTime),
}
} else {
proc["cpu"] = common.MapStr{
"total": common.MapStr{
"pct": GetProcCpuPercentage(last, process),
},
"start_time": process.Cpu.FormatStartTime(),
"start_time": unixTimeMsToTime(process.Cpu.StartTime),
}
}

Expand Down Expand Up @@ -304,3 +304,9 @@ func (procStats *ProcStats) GetProcStatsEvents() ([]common.MapStr, error) {

return events, nil
}

// unixTimeMsToTime converts a unix time given in milliseconds since Unix epoch
// to a common.Time value.
func unixTimeMsToTime(unixTimeMs uint64) common.Time {
return common.Time(time.Unix(0, int64(unixTimeMs*1000000)))
}

0 comments on commit 21852f6

Please sign in to comment.