-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the basic scaffolding for running the queries from the manifest
This was ported over from a working binary target and is being reworked into the lambda runtime which does introduce some complexities
- Loading branch information
Showing
4 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
# This is an example manifest fiule which configures the lambda | ||
gauges: | ||
# Each gauge should have a distinct name for managing inside of the lambda | ||
important_metric: | ||
# Then define a metric name to export to cloudwatch | ||
metric: 'last_10_uniq' | ||
url: 's3://example-bucket/databases/ds-partitioned-delta-table/' | ||
# Currently only a query handler type of `count` is supported | ||
type: count | ||
# The example Datafusion SQL query below queries the source table, which is defined by | ||
# the URL above, to find all the distinct uuids in the last 10 minutes of the current | ||
# `ds` partition. | ||
query: | | ||
SELECT DISTINCT uuid AS total FROM source | ||
WHERE ds = ARROW_CAST(CURRENT_DATE() , 'Utf8') | ||
AND created_at >= (ARROW_CAST(ARROW_CAST(NOW(), 'Timestamp(Second, None)'), 'Int64') - (60 * 10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use serde::Deserialize; | ||
use std::collections::HashMap; | ||
use std::convert::AsRef; | ||
use std::fs::File; | ||
use std::path::Path; | ||
|
||
use url::Url; | ||
#[derive(Debug, Deserialize)] | ||
pub struct Configuration { | ||
pub gauges: HashMap<String, Gauge>, | ||
} | ||
|
||
impl Configuration { | ||
pub fn from_file<S: Into<String> + AsRef<Path>>(location: S) -> Self { | ||
serde_yaml::from_reader(File::open(location).expect("Failed to open manifest")) | ||
.expect("Failed to deserialize") | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Gauge { | ||
pub url: Url, | ||
#[serde(rename = "type")] | ||
pub measurement_type: Measurement, | ||
pub query: String, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum Measurement { | ||
Count, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_config_deser() { | ||
let _conf: Configuration = Configuration::from_file("manifest.yml"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters