mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
Updating logger to support the use of retention policies
Also having the ecobee logger use it
This commit is contained in:
parent
b816715612
commit
09f6b1c728
@ -18,6 +18,8 @@ class ecobee extends external_api {
|
||||
protected static $log_influx = true;
|
||||
protected static $log_mysql = 'error';
|
||||
|
||||
protected static $influx_retention_policy = '30d';
|
||||
|
||||
protected static $cache = false;
|
||||
protected static $cache_for = null;
|
||||
|
||||
|
@ -22,6 +22,12 @@ class external_api extends cora\api {
|
||||
*/
|
||||
protected static $log_mysql = 'error';
|
||||
|
||||
/**
|
||||
* Default retention policy when inserting data. Autogen is the default
|
||||
* infinite one; also available is 30d.
|
||||
*/
|
||||
protected static $influx_retention_policy = 'autogen';
|
||||
|
||||
/**
|
||||
* Whether or not to cache API calls. This will store a hash of the request
|
||||
* and the response in the database and check there before performing the
|
||||
@ -230,7 +236,8 @@ class external_api extends cora\api {
|
||||
'http_code' => (int) $this->curl_info['http_code'],
|
||||
'connect_time' => round($this->curl_info['connect_time'], 4)
|
||||
],
|
||||
'timestamp' => $this->request_timestamp_microtime
|
||||
'timestamp' => $this->request_timestamp_microtime,
|
||||
'retention_policy' => $this::$influx_retention_policy
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -17,8 +17,10 @@ class logger extends cora\api {
|
||||
* Use these for things that need where clauses outside of timestamp.
|
||||
* @param array $fields At least one field. These are not indexed.
|
||||
* @param string $timestamp The timestamp in microseconds.
|
||||
* @param string $retention_policy The retention policy to write to.
|
||||
* Defaults to "autogen" which is infinite.
|
||||
*/
|
||||
public function log_influx($measurement, $tags, $fields, $timestamp) {
|
||||
public function log_influx($measurement, $tags, $fields, $timestamp, $retention_policy = null) {
|
||||
// If this is not configured, do not log.
|
||||
if(
|
||||
$this->setting->get('influx_database_host') === null ||
|
||||
@ -46,6 +48,7 @@ class logger extends cora\api {
|
||||
$this->setting->get('influx_database_port') .
|
||||
'/write' .
|
||||
'?db=' . $this->setting->get('influx_database_name') .
|
||||
($retention_policy !== null ? ('&rp=' . $retention_policy) : '') .
|
||||
'&precision=u';
|
||||
|
||||
exec(
|
||||
|
Loading…
x
Reference in New Issue
Block a user