-
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 Numeric metric type and add some documentation and tooling
- Loading branch information
Showing
9 changed files
with
169 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
.PHONY: help | ||
help: ## Show this help | ||
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: all build build-release check test clean | ||
all: check build test ## Perform all the checks builds and testing | ||
|
||
check: ## Ensure that the crate meets the basic formatting and structure | ||
cargo fmt --check | ||
cargo clippy | ||
|
||
build: ## Build the crate with each set of features | ||
./ci/build.sh | ||
|
||
build-release: check test ## Build the release versions of Lambdas | ||
./ci/build-release.sh | ||
test: ## Run the crate's tests with each set of features | ||
./ci/test.sh | ||
|
||
clean: ## Clean up resources from build | ||
cargo clean |
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,7 @@ | ||
#!/bin/sh | ||
|
||
if [ -f "${HOME}/.cargo/env" ]; then | ||
. "${HOME}/.cargo/env" | ||
fi; | ||
|
||
exec cargo lambda build --release --output-format zip |
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,11 @@ | ||
#!/bin/sh | ||
|
||
if [ -f "${HOME}/.cargo/env" ]; then | ||
. "${HOME}/.cargo/env" | ||
fi; | ||
|
||
set -xe | ||
|
||
cargo fmt --check | ||
|
||
exec cargo build |
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,6 @@ | ||
#!/bin/sh | ||
if [ -f "${HOME}/.cargo/env" ]; then | ||
. "${HOME}/.cargo/env" | ||
fi; | ||
|
||
exec cargo test --verbose |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "query-metrics" | ||
version = "0.3.0" | ||
version = "0.4.0" | ||
edition = "2021" | ||
|
||
[[bin]] | ||
|
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,50 @@ | ||
|
||
# query-metrics | ||
|
||
This Lambda will execute DataFusion queries defined in a YAML file and submit | ||
the results to CloudWatch Metrics which can be alerted upon or forwarded into | ||
other tools | ||
|
||
|
||
|
||
## Types | ||
|
||
### Count | ||
|
||
This is the simplest type of query and will simply record the number of rows from the query, e.g.: | ||
|
||
```sql | ||
SELECT id FROM source WHERE id > 1000 AND id <= 2000 | ||
``` | ||
|
||
Would consistently produce a counted metric value of `1000`. | ||
|
||
|
||
### Numeric | ||
|
||
Numeric is likely the most common and easy to understand query. There should only be one row in the result set and all of its values should be numeric values, e.g.: | ||
|
||
```sql | ||
SELECT COUNT(*) AS total, SUM(CASE WHEN (id > 1000 AND id <= 2000) THEN 1 ELSE 0 END) AS valid_ids FROM source | ||
``` | ||
|
||
This will produce a result set of: | ||
|
||
``` | ||
+-------+-----------+ | ||
| total | valid_ids | | ||
+-------+-----------+ | ||
| 4096 | 1000 | | ||
+-------+-----------+ | ||
``` | ||
|
||
Which wiull produce metric values of: | ||
|
||
* `total` 4096 | ||
* `valid_ids` 1000 | ||
|
||
|
||
### Dimensional Count | ||
|
||
The dimensional count is the most advanced query type and can be used to | ||
provide dimensional (or tagged) metrics in CloudWatch |
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
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