+ prometheus exporter sending
parent
5d0a362166
commit
e669f95c82
|
|
@ -2,7 +2,11 @@ CONFIG_SERVER_CREDS = "ws://ip.ip.ip.ip:port"
|
||||||
API_GRUBBER_SOCKET = "api-grubber.sock"
|
API_GRUBBER_SOCKET = "api-grubber.sock"
|
||||||
PREPROC_SOCKET = "preproc.sock"
|
PREPROC_SOCKET = "preproc.sock"
|
||||||
|
|
||||||
|
# PostgreSQL connection [DEPRECATED]
|
||||||
DB_HOST = "ip.addr.postgresql.server"
|
DB_HOST = "ip.addr.postgresql.server"
|
||||||
DB_USER = "db_user"
|
DB_USER = "db_user"
|
||||||
DB_PASSWORD = "db_user_password"
|
DB_PASSWORD = "db_user_password"
|
||||||
DB_DBNAME = "db_name"1
|
DB_DBNAME = "db_name"1
|
||||||
|
|
||||||
|
# Prometheus-Exporter info
|
||||||
|
EXPORTER_URL = "ip.ip.ip.ip:port"
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
use deadpool_postgres::{Config, Pool, Runtime, Client as PgClient};
|
use deadpool_postgres::{Config, Pool, Runtime, Client as PgClient};
|
||||||
|
use reqwest::Client;
|
||||||
use tokio_postgres::NoTls;
|
use tokio_postgres::NoTls;
|
||||||
use std::env;
|
use std::env;
|
||||||
use anyhow::{Error, Result};
|
use anyhow::{Result};
|
||||||
use log::{info, error};
|
use log::{info, error};
|
||||||
|
|
||||||
pub struct Exporter {
|
pub struct Exporter {
|
||||||
|
|
@ -35,7 +36,7 @@ impl Exporter {
|
||||||
pub fn is_no_connection(&self) -> bool { self.pool.is_none() }
|
pub fn is_no_connection(&self) -> bool { self.pool.is_none() }
|
||||||
pub fn init() -> Self {
|
pub fn init() -> Self {
|
||||||
Self {
|
Self {
|
||||||
pool : Self::pool_construct()
|
pool : Self::pool_construct(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn get_connection_from_pool(&self) -> Option<PgClient> {
|
pub async fn get_connection_from_pool(&self) -> Option<PgClient> {
|
||||||
|
|
@ -50,5 +51,16 @@ impl Exporter {
|
||||||
let _ = client.query(&query, &[&metrics]).await?;
|
let _ = client.query(&query, &[&metrics]).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
pub async fn export_metrics(metrics: &str) -> Result<()> {
|
||||||
|
let url = env::var("EXPORTER_URL")?;
|
||||||
|
// let req = Request::new(Method::PUT,
|
||||||
|
// Url::parse(metrics)?);
|
||||||
|
let req = Client::new()
|
||||||
|
.put(url)
|
||||||
|
.json(metrics)
|
||||||
|
.send().await;
|
||||||
|
req?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue