GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stackql/docs/analytics.md at main · stackql/stackql

Expand file tree

/

analytics.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
120 lines (101 loc) · 3.43 KB
/

analytics.md

Copy path

File metadata and controls

120 lines (101 loc) · 3.43 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Analytics with stackql

The canonical pattern is a postgres backend. To meaningfully develop analytics capability, real authenticated access to providers plus a postgres backend is needed. Therefore for local development:

  • Ensure that all env var secrets are exported from the .gitignored file cicd/vol/vendor-secrets/secrets.sh.
  • Run and kill development containers with docker compose -f docker-compose-live.yml down --volumes / docker compose -f docker-compose-live.yml up --force-recreate.
  • Connect and develop queries with psql "postgresql://stackql:[email protected]:8632/stackql".

TODO

Robot tests for:

  • Support for current_date.
  • Support for current_timestamp.
  • Support for multi-layered table valued functions in subqueries with outside filters, per Figure MLS-01.

-- sqlite version

CREATE OR REPLACE MATERIALIZED VIEW gcp_compute_public_ip_exposure AS
select
  resource_type,
  resource_id,
  resource_name,
  cloud,
  region,
  protocol,
  from_port,
  to_port,
  cidr,
  direction,
  public_access_type,
  public_principal,
  access_mechanism
from 
(
SELECT
  'compute'                          AS resource_type,
  vms.id                                 AS resource_id,
  vms.name                               AS resource_name,
  'google'                              AS cloud,
  split_part(vms.zone, '/', -1)      AS region,
  NULL                               AS protocol,
  NULL                               AS from_port,
  NULL                               AS to_port,
  NULL                               AS cidr,
  NULL                               AS direction,
  NULL                               AS public_access_type,
  NULL                               AS public_principal,
  NULL                               AS access_mechanism,
  json_extract(ac.value, '$.natIP') as external_ip
FROM google.compute.instances vms,
  json_each(vms.networkInterfaces) AS ni,
  json_each(json_extract(ni.value, '$.accessConfigs')) AS ac
WHERE 
  vms.project in (
    'testing-project'
  )
  ) foo
  where external_ip != ''
;


-- postgres version

CREATE OR REPLACE MATERIALIZED VIEW gcp_compute_public_ip_exposure AS
select
  resource_type,
  resource_id,
  resource_name,
  cloud,
  region,
  protocol,
  from_port,
  to_port,
  cidr,
  direction,
  public_access_type,
  public_principal,
  access_mechanism
from 
(
SELECT
  'compute'                          AS resource_type,
  vms.id                                 AS resource_id,
  vms.name                               AS resource_name,
  'google'                              AS cloud,
  split_part(vms.zone, '/', -1)      AS region,
  NULL                               AS protocol,
  NULL                               AS from_port,
  NULL                               AS to_port,
  NULL                               AS cidr,
  NULL                               AS direction,
  NULL                               AS public_access_type,
  NULL                               AS public_principal,
  NULL                               AS access_mechanism,
  json_extract_path_text(ac.value, 'natIP') as external_ip
FROM google.compute.instances vms,
  json_array_elements_text(vms.networkInterfaces) AS ni,
  json_array_elements_text(json_extract_path_text(ni.value, 'accessConfigs')) AS ac
WHERE 
  vms.project in (
    'stackql-interesting'
  )
  ) foo
  where external_ip != ''
;

Figure MLS-01: Multi-layered table valued functions in subqueries with outside filters.


You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.