Skip to content

Commit 3106679

Browse files
committed
Add time annotations
ankane#402
1 parent 5317681 commit 3106679

File tree

13 files changed

+1108
-34
lines changed

13 files changed

+1108
-34
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2024 Andrew Kane
1+
Copyright (c) 2014-2025 Andrew Kane
22

33
MIT License
44

README.md

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
176176
COMMIT;
177177
```
178178

179-
### MySQL
179+
### MySQL and MariaDB
180180

181181
Create a user with read-only permissions:
182182

@@ -284,6 +284,32 @@ smart_columns:
284284
status: {0: "Active", 1: "Archived"}
285285
```
286286

287+
### Annotations
288+
289+
Shows overlay lines or box ranges for line queries.
290+
291+
Suppose your sales data and your deployments data, given a query:
292+
293+
```sql
294+
SELECT date_trunc('hour', created_at), sum(value) FROM sales GROUP BY 1
295+
```
296+
297+
You might want to see the influence of a deployment for those sales.
298+
299+
```yml
300+
annotations:
301+
deployments: SELECT date, name FROM deployments WHERE date BETWEEN {min_date} AND {max_date}
302+
```
303+
304+
You can also show periods:
305+
306+
```yml
307+
annotations:
308+
holidays: SELECT min_date, max_date, name FROM holidays WHERE (min_date, max_date) OVERLAPS ({min_date}, {max_date})
309+
```
310+
311+
Conditions for those queries are optional, but they will help to only fetch the relevant annotations for a particular chart.
312+
287313
### Caching
288314

289315
Blazer can automatically cache results to improve speed. It can cache slow queries:
@@ -448,24 +474,22 @@ anomaly_checks: prophet
448474

449475
### Trend
450476

451-
[Trend](https://trendapi.org/) uses an external service by default, but you can run it on your own infrastructure as well.
452-
453477
Add [trend](https://github.com/ankane/trend) to your Gemfile:
454478

455479
```ruby
456480
gem "trend"
457481
```
458482

459-
And add to `config/blazer.yml`:
483+
Set the URL to the [API](https://github.com/ankane/trend-api) in an initializer:
460484

461-
```yml
462-
anomaly_checks: trend
485+
```ruby
486+
Trend.url = "http://localhost:8000"
463487
```
464488

465-
For the [self-hosted API](https://github.com/ankane/trend-api), create an initializer with:
489+
And add to `config/blazer.yml`:
466490

467-
```ruby
468-
Trend.url = "http://localhost:8000"
491+
```yml
492+
anomaly_checks: trend
469493
```
470494

471495
### AnomalyDetection.rb
@@ -504,24 +528,22 @@ forecasting: prophet
504528

505529
### Trend
506530

507-
[Trend](https://trendapi.org/) uses an external service by default, but you can run it on your own infrastructure as well.
508-
509531
Add [trend](https://github.com/ankane/trend) to your Gemfile:
510532

511533
```ruby
512534
gem "trend"
513535
```
514536

515-
And add to `config/blazer.yml`:
537+
Set the URL to the [API](https://github.com/ankane/trend-api) in an initializer:
516538

517-
```yml
518-
forecasting: trend
539+
```ruby
540+
Trend.url = "http://localhost:8000"
519541
```
520542

521-
For the [self-hosted API](https://github.com/ankane/trend-api), create an initializer with:
543+
And add to `config/blazer.yml`:
522544

523-
```ruby
524-
Trend.url = "http://localhost:8000"
545+
```yml
546+
forecasting: trend
525547
```
526548

527549
## Uploads
@@ -583,7 +605,7 @@ data_sources:
583605
- [Google BigQuery](#google-bigquery)
584606
- [IBM DB2 and Informix](#ibm-db2-and-informix)
585607
- [InfluxDB](#influxdb)
586-
- [MySQL](#mysql-1)
608+
- [MySQL and MariaDB](#mysql-and-mariadb-1)
587609
- [Neo4j](#neo4j)
588610
- [OpenSearch](#opensearch)
589611
- [Oracle](#oracle)
@@ -656,11 +678,11 @@ Here’s an example IAM policy:
656678
}
657679
```
658680

659-
You also need to configure [S3 permissions](https://aws.amazon.com/premiumsupport/knowledge-center/access-denied-athena/).
681+
You also need to configure [S3 permissions](https://repost.aws/knowledge-center/access-denied-athena).
660682

661683
### Amazon Redshift
662684

663-
Add [activerecord6-redshift-adapter](https://github.com/kwent/activerecord6-redshift-adapter) or [activerecord5-redshift-adapter](https://github.com/ConsultingMD/activerecord5-redshift-adapter) to your Gemfile and set:
685+
Add [activerecord7-redshift-adapter-pennylane](https://github.com/pennylane-hq/activerecord-adapter-redshift) to your Gemfile and set:
664686

665687
```yml
666688
data_sources:
@@ -735,7 +757,7 @@ Use a [read-only role](https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/us
735757

736758
### Druid
737759

738-
Enable [SQL support](http://druid.io/docs/latest/querying/sql.html#configuration) on the broker and set:
760+
Enable [SQL support](https://druid.apache.org/docs/latest/querying/sql) on the broker and set:
739761

740762
```yml
741763
data_sources:
@@ -761,7 +783,7 @@ Use a [read-only role](https://www.elastic.co/guide/en/elasticsearch/reference/c
761783

762784
### Google BigQuery
763785

764-
Add [google-cloud-bigquery](https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-bigquery) to your Gemfile and set:
786+
Add [google-cloud-bigquery](https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/main/google-cloud-bigquery) to your Gemfile and set:
765787

766788
```yml
767789
data_sources:
@@ -796,7 +818,7 @@ data_sources:
796818

797819
Use a [read-only user](https://docs.influxdata.com/influxdb/v1.8/administration/authentication_and_authorization/). Supports [InfluxQL](https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/).
798820

799-
### MySQL
821+
### MySQL and MariaDB
800822

801823
Add [mysql2](https://github.com/brianmario/mysql2) to your Gemfile (if it’s not there) and set:
802824

@@ -806,7 +828,7 @@ data_sources:
806828
url: mysql2://user:password@hostname:3306/database
807829
```
808830

809-
Use a [read-only user](#mysql).
831+
Use a [read-only user](#mysql-and-mariadb).
810832

811833
### Neo4j
812834

@@ -860,7 +882,7 @@ Use a [read-only user](#postgresql).
860882

861883
### Presto
862884

863-
Add [presto-client](https://github.com/treasure-data/presto-client-ruby) to your Gemfile and set:
885+
Add [trino-client](https://github.com/treasure-data/trino-client-ruby) to your Gemfile and set:
864886

865887
```yml
866888
data_sources:
@@ -930,7 +952,7 @@ https://sfc-repo.snowflakecomputing.com/odbc/linux/2.21.5/snowflake-odbc-2.21.5.
930952

931953
> This installs the driver at `/app/.apt/usr/lib/snowflake/odbc/lib/libSnowflake.so`
932954

933-
Then, download the [Snowflake ODBC driver](https://docs.snowflake.net/manuals/user-guide/odbc-download.html). Add [odbc_adapter](https://github.com/localytics/odbc_adapter) to your Gemfile and set:
955+
Then, download the [Snowflake ODBC driver](https://docs.snowflake.com/developer-guide/odbc/odbc-download). Add [odbc_adapter](https://github.com/localytics/odbc_adapter) to your Gemfile and set:
934956

935957
```yml
936958
data_sources:
@@ -1011,10 +1033,6 @@ Have team members who want to learn SQL? Here are a few great, free resources.
10111033

10121034
For an easy way to group by day, week, month, and more with correct time zones, check out [Groupdate.sql](https://github.com/ankane/groupdate.sql).
10131035

1014-
## Standalone Version
1015-
1016-
Looking for a standalone version? Check out [Ghost Blazer](https://github.com/buren/ghost_blazer).
1017-
10181036
## Performance
10191037

10201038
By default, queries take up a request while they are running. To run queries asynchronously, add to your config:

app/assets/javascripts/blazer/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//= require ./chartjs-adapter-date-fns.bundle
1313
//= require ./chartkick
1414
//= require ./mapkick.bundle
15+
//= require ./chartjs-plugin-annotation.js
1516
//= require ./ace
1617
//= require ./Sortable
1718
//= require ./bootstrap

0 commit comments

Comments
 (0)