Skip to content

Instantly share code, notes, and snippets.

@suhlig
Created January 15, 2023 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suhlig/952822a8461bd448e821181ae18ead14 to your computer and use it in GitHub Desktop.
Save suhlig/952822a8461bd448e821181ae18ead14 to your computer and use it in GitHub Desktop.
Pulling simple container metrics with jq
  • Container count by pipeline

    $ fly -t uh cs --json | jq -r '[group_by(.pipeline_name)[] | {(.[0].pipeline_name): length }] | add'
    {
      "concourse-resource-proxy": 2,
      "concourse-rss-resource": 2,
      "env-sensors": 7,
      "forwardemail-webhook-rs": 2,
      "mosquitto-prometheus-exporter": 7,
      "pinboard": 3,
      "plaintweet": 7,
      "postgres-release-monitor": 1,
      "pypi-resource": 2,
      "regional-sales": 6,
      "regional-sales-instances": 2,
      "rustomato": 2,
      "task-library": 6,
      "tasmota-sensor-bridge": 14,
      "video-archive": 9,
      "webservices": 24
    }
  • As TSV

    $ fly -t uh cs --json | jq -r '[ group_by(.pipeline_name)[] | {(.[0].pipeline_name): length } ] | add | to_entries | .[] | [.key, .value] | @tsv'
    concourse-resource-proxy        2
    concourse-rss-resource  2
    env-sensors     7
    forwardemail-webhook-rs 2
    mosquitto-prometheus-exporter   7
    pinboard        3
    plaintweet      7
    postgres-release-monitor        1
    pypi-resource   2
    regional-sales  6
    regional-sales-instances        2
    rustomato       2
    task-library    6
    tasmota-sensor-bridge   14
    video-archive   9
    webservices     24
  • Transposed TSV

    $ fly -t uh cs --json | jq -r '[ group_by(.pipeline_name)[] | {(.[0].pipeline_name): length } ] | add | to_entries | .[] | [.key, .value]' | jq -rs 'transpose | .[] | @tsv'
    concourse-resource-proxy        concourse-rss-resource  env-sensors     forwardemail-webhook-rs mosquitto-prometheus-exporter   pinboard        plaintweet      postgres-release-monitor    pypi-resource   regional-sales  regional-sales-instances        rustomato       task-library    tasmota-sensor-bridge   video-archive   webservices
    1       3       9       2       7       4       7       2       2       6       2       2       8       11      11      23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment