Skip to content

Commit

Permalink
Use RFC3339 format for timestamps in SQL module (elastic#15847)
Browse files Browse the repository at this point in the history
This way timezone and more precise information is stored in the final
events in case they are lately parsed as dates.
  • Loading branch information
jsoriano authored Jan 27, 2020
1 parent 8260623 commit 121f19d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Metricbeat*

- Use RFC3339 format for timestamps collected using the SQL module. {pull}15847[15847]


*Packetbeat*

Expand Down
16 changes: 8 additions & 8 deletions x-pack/metricbeat/module/sql/query/_meta/data_postgres.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"period": 10000
},
"service": {
"address": "172.22.0.2:5432",
"address": "192.168.0.3:5432",
"type": "sql"
},
"sql": {
Expand All @@ -19,27 +19,27 @@
"numeric": {
"blk_read_time": 0,
"blk_write_time": 0,
"blks_hit": 1923,
"blks_read": 111,
"blks_hit": 948,
"blks_read": 96,
"conflicts": 0,
"datid": 12379,
"deadlocks": 0,
"numbackends": 1,
"temp_bytes": 0,
"temp_files": 0,
"tup_deleted": 0,
"tup_fetched": 1249,
"tup_fetched": 616,
"tup_inserted": 0,
"tup_returned": 1356,
"tup_returned": 717,
"tup_updated": 0,
"xact_commit": 18,
"xact_commit": 3,
"xact_rollback": 0
},
"string": {
"datname": "postgres",
"stats_reset": "2020-01-21 11:23:56.53"
"stats_reset": "2020-01-25T18:21:44.869405Z"
}
},
"query": "select * from pg_stat_database"
"query": "select * from pg_stat_database where datname='postgres'"
}
}
2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/sql/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func getValue(pval *interface{}) string {
case []byte:
return string(v)
case time.Time:
return v.Format("2006-01-02 15:04:05.999")
return v.Format(time.RFC3339Nano)
default:
return fmt.Sprint(v)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestPostgreSQL(t *testing.T) {

config = testFetchConfig{
Driver: "postgres",
Query: "select * from pg_stat_database",
Query: "select * from pg_stat_database where datname='postgres'",
Host: fmt.Sprintf("postgres://%s:%s@%s:%s/?sslmode=disable", user, password, host, port),
Assertion: assertFieldNotContains("service.address", ":"+password+"@"),
}
Expand Down

0 comments on commit 121f19d

Please sign in to comment.