I call it "prodder" I pull data from toggl (a tool...
# show-us-what-you-got
v
I call it "prodder" I pull data from toggl (a tool I use to track my time). If I'm not logging time every 30 minutes I get a notification in slack.
Copy code
version: 1
default_environment: dev
project_id: 837f43f8-6634-49ee-b053-82f42a840c54
plugins:
  extractors:
  - name: tap-toggl
    namespace: tap_toggl
    pip_url: git+<https://github.com/AutoIDM/tap-toggl.git@current_time_entries>
    executable: tap-toggl
    capabilities:
    - catalog
    - discover
    - state
    settings:
    - name: api_token
      kind: password
    - name: detailed_report_trailing_days
      kind: integer
    - name: start_date
      kind: string
    - name: user_agent
      kind: string
  - name: tap-postgres
    variant: transferwise
    pip_url: pipelinewise-tap-postgres 
    config:
      host: localhost
      post: 5432
      user: postgres
      password: postgres
      dbname: postgres
      default_replication_method: FULL_TABLE
    select:
    - autoidm-target_slack.*
  loaders:
  - name: target-postgres
    variant: transferwise
    pip_url: git+<https://github.com/transferwise/pipelinewise-target-postgres.git@dependabot/pip/psycopg2-binary-2.9.4>
    config:
      host: localhost
      post: 5432
      user: postgres
      password: postgres
      dbname: postgres
  - name: target-apprise
    namespace: target_apprise
    pip_url: target-apprise
    executable: target-apprise
    settings:
    - name: uris
      kind: array
  transformers:
  - name: dbt
    pip_url: dbt-core~=1.0.0 dbt-postgres~=1.0.0 dbt-redshift~=1.0.0 dbt-snowflake~=1.0.0
      dbt-bigquery~=1.0.0
    config:
      target: postgres
      host: localhost
      port: 5432
      user: postgres
      dbname: postgres
      project_dir: $MELTANO_PROJECT_ROOT/transform
      PROFILES_DIR: $MELTANO_PROJECT_ROOT/transform/profile
      source_schema: $MELTANO_LOAD__TARGET_SCHEMA
      target_schema: autoidm
      models: my_meltano_project
  files:
  - name: dbt
    pip_url: git+<https://gitlab.com/meltano/files-dbt.git@config-version-2>
environments:
- name: dev
  config:
    plugins:
      extractors:
      - name: tap-toggl
        config:
          detailed_report_trailing_days: 3
          start_date: '2022-04-03'
          user_agent: AutoIDM
- name: staging
- name: prod
Dockerfile
Copy code
stages:
- build
- run

#Only triggered via a scheduled run. We pull the latest Docker image to run the job with
#Using the docker image is faster to run as we don't have to install meltano or the tap/target packages
runner:
  image:
    name: $CI_REGISTRY_IMAGE:latest
    entrypoint: [""]
  before_script:
  - cp -Rn /project/. . #Copy meltano project into image
  stage: run
  variables:
    TARGET_POSTGRES_PASSWORD: $TAP_POSTGRES_PASSWORD
    TARGET_POSTGRES_HOST: $TAP_POSTGRES_HOST
    DBT_HOST: $TAP_POSTGRES_HOST
    DBT_PASSWORD: $TAP_POSTGRES_PASSWORD
    POSTGRES_PASSWORD: $TAP_POSTGRES_PASSWORD

  services:
  - name: postgres
  script:
  - "meltano run tap-toggl target-postgres dbt:run tap-postgres target-apprise"
  rules:
    - if: $CI_PIPELINE_SOURCE == "trigger"

# Tags <project>:<sha>
# Tags <project>:<ref> (<branch> or <tag>)
# Tags <project>:latest
# Saves us time by building the Docker file once when things change. Runner runs a lot (every 15 minutes or so), docker-build-latest runs infreqently
docker-build-latest:
  stage: build
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
    MELTANO_IMAGE: meltano/meltano
  before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME || true
  services: ["docker:dind"]
  script:
  - >
    docker build
    --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
    --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
    --build-arg MELTANO_IMAGE=$MELTANO_IMAGE
    .
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
  - docker push $CI_REGISTRY_IMAGE:latest
  rules:
  - if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE != "trigger"
d
Awesome! What does this do? 😄 Can you please add a little more context to the post for the benefit of this channel’s 2785 members? 😜
v
Added a bit to the first message @douwe_maan! Was chatting with AJ and just wanted to get something out here
a
Thanks for sharing, @visch. This is a nice example of Meltano being used for a non-traditional application. 👍 I also really like the use of target-apprise to send slack messages.
s
Nice share! Now it was officially worth it to open up this channel 😄