Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Integration: Snowflake #7043

Merged
merged 77 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
829cb9f
Add snowflake intg
ChristineTChen Jun 15, 2020
3dbe6fb
Add dep
ChristineTChen Jun 26, 2020
b147f87
Add auth options
ChristineTChen Jun 26, 2020
98a6d92
Validate config options
ChristineTChen Jun 26, 2020
1a97c14
set config options
ChristineTChen Jun 26, 2020
8eae1ed
Set up connection obj
ChristineTChen Jun 26, 2020
b0e17cf
Add storage usage query
ChristineTChen Jun 27, 2020
13b2714
use dd_check_run fixture
ChristineTChen Jun 30, 2020
6a12e21
Add execute query
ChristineTChen Jun 30, 2020
a0b0604
Add metric usage query
ChristineTChen Jul 2, 2020
f82cf74
Add warehouse credit usage
ChristineTChen Jul 8, 2020
23f2d88
Collect metadata version
ChristineTChen Jul 8, 2020
34d5a6d
Add mocked test
ChristineTChen Jul 22, 2020
f01cec4
Add test for metering metrics
ChristineTChen Jul 23, 2020
92ef8b6
override min collection interval
ChristineTChen Jul 23, 2020
3c3f8f8
Update
ChristineTChen Jul 24, 2020
e114935
Override min_collect_interval
ChristineTChen Jul 24, 2020
f11cd11
add metrics
ChristineTChen Jul 24, 2020
59a950d
Update last ts
ChristineTChen Jul 25, 2020
317ccf2
Add test coverage
ChristineTChen Aug 20, 2020
98effef
Add login metrics
ChristineTChen Aug 20, 2020
de12618
Add warehouse load metrics
ChristineTChen Aug 21, 2020
7eef168
fix CI
ChristineTChen Aug 22, 2020
486d0ab
Pin deps
ChristineTChen Aug 25, 2020
55af0fa
Add metrics to metadata
ChristineTChen Aug 25, 2020
bddde75
Add query history metrics
ChristineTChen Aug 25, 2020
7d03f22
Get parts from last ts
ChristineTChen Aug 25, 2020
1321c25
initial min collection interval
ChristineTChen Aug 25, 2020
f97f10f
set default for min collect
ChristineTChen Aug 25, 2020
73d1214
Add query history metrics
ChristineTChen Aug 25, 2020
1258762
pin dep to 2.1.3
ChristineTChen Aug 25, 2020
b9d812e
Ensure queries convert start_time column to UTC
ChristineTChen Aug 25, 2020
e485ef3
Fix style
ChristineTChen Aug 25, 2020
22b0b4f
Increase latency timestamp to 3 hours
ChristineTChen Aug 25, 2020
c9838f0
remove last ts concept and collect metrics by day
ChristineTChen Aug 26, 2020
af927cc
Update manifest
ChristineTChen Aug 26, 2020
239d436
Add sc
ChristineTChen Aug 26, 2020
8a14a7e
Add readme
ChristineTChen Aug 26, 2020
4ae0d00
Remove conversion and use local time
ChristineTChen Aug 26, 2020
f30aa35
Add metric groups
ChristineTChen Aug 27, 2020
f9bec33
Use check_name constant in tests
ChristineTChen Aug 27, 2020
5abe144
Test metric group config
ChristineTChen Aug 27, 2020
01490d6
Test queries
ChristineTChen Aug 27, 2020
e56619f
Clean up
ChristineTChen Aug 27, 2020
80570b9
Update billing metrics
ChristineTChen Aug 27, 2020
ac6d1c4
Fix style
ChristineTChen Aug 27, 2020
64fc7c4
remove format string from log line
ChristineTChen Aug 28, 2020
55dc1f6
Add test for version metadata
ChristineTChen Aug 28, 2020
10574dd
Add data transfer metrics
ChristineTChen Aug 28, 2020
5458afc
Add auto recluster metrics
ChristineTChen Aug 28, 2020
e158215
Add table storage metrics
ChristineTChen Aug 28, 2020
327b86b
Add pipe metrics
ChristineTChen Aug 31, 2020
d0ddadb
Add replication metrics
ChristineTChen Aug 31, 2020
17adf11
Add custom queries
ChristineTChen Aug 31, 2020
b3c3083
Fix tests
ChristineTChen Aug 31, 2020
bdd78da
Update readme
ChristineTChen Sep 1, 2020
85b9e92
Add rec mon
ChristineTChen Sep 3, 2020
f3b8fbd
Update with feedback
ChristineTChen Sep 3, 2020
9861a98
Add missing option
ChristineTChen Sep 4, 2020
640b69d
Update snowflake/requirements-dev.txt
ChristineTChen Sep 11, 2020
2e36111
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
9fc1bda
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
fba4287
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
6d199d7
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
eb204d5
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
0dda647
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
e2a4f39
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
ae7a8f9
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
23f7faf
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
a1999b9
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
eab81e1
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
f05ec49
Update snowflake/datadog_checks/snowflake/queries.py
ChristineTChen Sep 11, 2020
835549c
Merge branch 'cc/snowflake' of github.com:DataDog/integrations-core i…
ChristineTChen Sep 11, 2020
fc1c980
Make db and schema customizable
ChristineTChen Sep 11, 2020
0c06f2a
Retry connection if closed
ChristineTChen Sep 14, 2020
34baee0
Merge branch 'master' into cc/snowflake
ofek Sep 16, 2020
2b12ecb
clean up
ofek Sep 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .azure-pipelines/templates/test-all-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ jobs:
- checkName: snmp
displayName: SNMP
os: linux
- checkName: snowflake
displayName: Snowflake
os: linux
- checkName: solr
displayName: Solr
os: linux
Expand Down
9 changes: 9 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ coverage:
target: 75
flags:
- scylla
Snowflake:
target: 75
flags:
- snowflake
Spark:
target: 75
flags:
Expand Down Expand Up @@ -1041,6 +1045,11 @@ flags:
paths:
- snmp/datadog_checks/snmp
- snmp/tests
snowflake:
carryforward: true
paths:
- snowflake/datadog_checks/snowflake
- snowflake/tests
spark:
carryforward: true
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ serpent==1.27; sys_platform == 'win32'
service_identity[idna]==18.1.0
simplejson==3.6.5
six==1.14.0
snowflake-connector-python==2.1.3
supervisor==4.1.0
tuf==0.12.2
typing==3.7.4.1; python_version < '3.0'
Expand Down
2 changes: 2 additions & 0 deletions snowflake/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CHANGELOG - Snowflake

10 changes: 10 additions & 0 deletions snowflake/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
graft datadog_checks
graft tests

include MANIFEST.in
include README.md
include requirements.in
include requirements-dev.txt
include manifest.json

global-exclude *.py[cod] __pycache__
57 changes: 57 additions & 0 deletions snowflake/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Agent Check: Snowflake

## Overview

This check monitors [Snowflake][1] through the Datadog Agent. Snowflake is a SaaS-analytic data warehouse and runs completely on cloud infrastructure.
This integration monitors credit, billing, and storage usage, query history, and more.

**NOTE**: Metrics are collected via queries to Snowflake. Queries from the integration are billable by Snowflake.

## Setup

Follow the instructions below to install and configure this check for an Agent running on a host.

### Installation

The Snowflake check is included in the [Datadog Agent][2] package.
No additional installation is needed on your server.

### Configuration

1. Edit the `snowflake.d/conf.yaml` file, in the `conf.d/` folder at the root of your Agent's configuration directory to start collecting your snowflake performance data. See the [sample snowflake.d/conf.yaml][3] for all available configuration options.

**Note**: By default, this integration monitors the `SNOWFLAKE` database and `ACCOUNT_USAGE` schema.
This database is available by default and only viewable by users in the `ACCOUNTADMIN` role or [any role granted by the ACCOUNTADMIN][8].

2. [Restart the Agent][4].

### Validation

[Run the Agent's status subcommand][5] and look for `snowflake` under the Checks section.

## Data Collected

### Metrics

See [metadata.csv][6] for a list of metrics provided by this check.

### Service Checks

`snowflake.can_connect`: Returns `CRITICAL` if the Agent cannot authenticate and connect to Snowflake, `OK` otherwise.

### Events

Snowflake does not include any events.

## Troubleshooting

Need help? Contact [Datadog support][7].

[1]: https://www.snowflake.com/
[2]: https://docs.datadoghq.com/agent/kubernetes/integrations/
[3]: https://github.com/DataDog/integrations-core/blob/master/snowflake/datadog_checks/snowflake/data/conf.yaml.example
[4]: https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent
[5]: https://docs.datadoghq.com/agent/guide/agent-commands/#agent-status-and-information
[6]: https://github.com/DataDog/integrations-core/blob/master/snowflake/metadata.csv
[7]: https://docs.datadoghq.com/help/
[8]: https://docs.snowflake.com/en/sql-reference/account-usage.html#enabling-account-usage-for-other-roles
119 changes: 119 additions & 0 deletions snowflake/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Snowflake
files:
- name: snowflake.yaml
options:
- template: init_config
options:
- template: init_config/db
- template: init_config/default
- template: instances
options:
- name: account
required: true
description: |
Name of your account (provided by Snowflake), including the platform and region if applicable.
ChristineTChen marked this conversation as resolved.
Show resolved Hide resolved
For more information on Snowflake account names,
see https://docs.snowflake.com/en/user-guide/connecting.html#your-snowflake-account-name
value:
type: string
example: <ACCOUNT>
- name: user
required: true
description: Login name for the user.
value:
type: string
example: <USER>
- name: password
required: true
description: Password for the user
value:
type: string
example: <PASSWORD>
- name: database
description: Name of the default database to use.
value:
type: string
example: SNOWFLAKE
- name: schema
description: Name of the default schema to use for the database.
value:
type: string
example: ACCOUNT_USAGE
- name: role
description: Name of the default role to use.
value:
type: string
example: ACCOUNTADMIN
- name: warehouse
description: Name of the default warehouse to use.
value:
type: string
example: <WAREHOUSE>
- name: client_prefetch_threads
description: |
The number of threads used to download the results sets. Increasing the value improves fetch
performance but requires more memory.
value:
type: integer
example: 4
- name: login_timeout
description: |
Timeout in seconds for login. The login request gives up after the timeout length if the HTTP response succeeds.
value:
type: integer
example: 60
- name: ocsp_response_cache_filename
description: |
Path for the OCSP response cache file. By default, the file is created in the cache directory:
Linux - ~/.cache/snowflake/ocsp_response_cache
macOS - ~/Library/Caches/Snowflake/ocsp_response_cache
Windows - %USERPROFILE%\AppData\Local\Snowflake\Caches\ocsp_response_cache
value:
type: string
example: <OCSP_RESPONSE_CACHE_FILENAME>
- name: metric_groups
description: |
List Snowflake metric groups to collect. Metric groups are determined by the metric prefixes.

The available metric groups are:

- snowflake.query
- snowflake.billing
- snowflake.storage
- snowflake.storage.database
- snowflake.storage.table
- snowflake.logins
- snowflake.data_transfer
- snowflake.auto_recluster
- snowflake.pipe
- snowflake.replication
value:
type: array
items:
type: string
example:
- snowflake.query
- snowflake.billing
- snowflake.storage
- snowflake.logins
- template: instances/db
overrides:
custom_queries.value.example:
- query: SELECT foo, COUNT(*) FROM table.events GROUP BY foo
columns:
- name: foo
type: tag
- name: event.total
type: gauge
tags:
- test:snowflake
- template: instances/default
overrides:
min_collection_interval.description: |
This changes the collection interval of the check. For more information, see:
https://docs.datadoghq.com/developers/write_agent_check/#collection-interval

NOTE: Most Snowflake ACCOUNT_USAGE views are populated on an hourly basis,
so to minimize unnecessary queries the `min_collection_interval` defaults to 1 hour.
min_collection_interval.default: 3600
min_collection_interval.value.example: 3600
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "[Snowflake] Increased Failed Login Attempts",
"type": "metric alert",
"query": "sum(last_1d):avg:snowflake.logins.fail.count{*}.as_count() > 3",
"message": "There has been at least 3 failed login attempts in the past 24 hours. ",
"tags": [
"integration:snowflake"
],
"options": {
"notify_audit": false,
"locked": false,
"timeout_h": 0,
"new_host_delay": 300,
"require_full_window": true,
"notify_no_data": false,
"renotify_interval": "0",
"escalation_message": "",
"no_data_timeframe": null,
"include_tags": true,
"thresholds": {
"critical": 3
}
},
"recommended_monitor_metadata": {
"description": "Notify your team when there has been increased failed login attempts to your account."
}
}
17 changes: 17 additions & 0 deletions snowflake/assets/service_checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"agent_version": "7.23.0",
"integration": "Snowflake",
"groups": [
"host",
"endpoint"
],
"check": "snowflake.can_connect",
"statuses": [
"ok",
"critical"
],
"name": "Snowflake can connect",
"description": "Returns `CRITICAL` if the check cannot authenticate Snowflake credentials. Returns `OK` otherwise."
}
]
4 changes: 4 additions & 0 deletions snowflake/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
4 changes: 4 additions & 0 deletions snowflake/datadog_checks/snowflake/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__version__ = '0.0.1'
7 changes: 7 additions & 0 deletions snowflake/datadog_checks/snowflake/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__
from .check import SnowflakeCheck

__all__ = ['__version__', 'SnowflakeCheck']
Loading