Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created December 17, 2022 00:42
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 maxandersen/83688176e98e6ed6d7d8e7399b001094 to your computer and use it in GitHub Desktop.
Save maxandersen/83688176e98e6ed6d7d8e7399b001094 to your computer and use it in GitHub Desktop.
properties:
GoalsFunction: AVERAGE
SeriesColor: cyan
global:
mode: dark
settings:
extraConfiguration: >-
{
"color": "${SeriesColor}"
}
axis:
y:
title: "AVG Goals"
chart:
resizable: true
height: 300
grid:
y: false
x: false
html:
html: >-
<div id="${this}" class="card-pf card-pf-aggregate-status" style="margin: 15px; background-color: ${bgColor}; height: 85px; border-radius: 10px">
<h2 style="font-weight: 600; font-size: x-large" id="${this}Value">${value}</h2>
<p style="font-weight: 400" id="${this}Title"><em id="${this}Icon" class=""></em> ${title}</p>
</div>
export:
png: true
lookup:
uuid: fifa_matches
datasets:
- uuid: fifa_matches
url: https://api.fifa.com/api/v3/calendar/matches?from=2022-11-20T00%3A00%3A00Z&to=2022-12-20T23%3A59%3A59Z&language=en&count=500&idSeason=255711
cacheEnabled: "true"
expression: >-
$.Results.[
( $.MatchStatus = 0 ?
[
$.IdMatch,
$.LocalDate = null ? "" : $.LocalDate,
$toMillis($.LocalDate) ~> $fromMillis('[D]-[M]-[Y]'),
$toMillis($.LocalDate) ~> $fromMillis('[H]:[m]'),
$.Weather.Humidity != null ? $.Weather.Humidity : "-1",
$.Weather.Temperature != null ? $.Weather.Temperature : "-1",
$.Weather.WindSpeed != null ? $.Weather.WindSpeed : "-1",
$.Weather.TypeLocalized[0].Description != null ? $.Weather.TypeLocalized[0].Description : "",
$.Home.IdCountry != null ? $.Home.IdCountry : "",
$.Home.ShortClubName != null ? $.Home.ShortClubName : "",
$.HomeTeamScore != null ? $.HomeTeamScore : "-1",
$.Away.IdCountry != null ? $.Away.IdCountry : "",
$.Away.ShortClubName != null ? $.Away.ShortClubName : "",
$.Away.Score != null ? $.Away.Score : "-1",
$.Stadium.Name[0].Description,
$.Stadium.CityName[0].Description,
$.Attendance != null ? $.Attendance : "-1",
$.HomeTeamScore + $.AwayTeamScore,
$join([$.Home.ShortClubName, $.Away.ShortClubName], ' vs ')
]
)
]
columns:
- id: ID
type: LABEL
- id: Date
type: LABEL
- id: Day
type: Label
- id: Hour
type: Label
- id: Humidity
type: Number
- id: Temperature
type: NUMBER
- id: WindSpeed
type: NUMBER
- id: Weather
type: LABEL
- id: Team 1 Country
type: LABEL
- id: Team 1 Name
type: LABEL
- id: Team 1 Score
type: NUMBER
- id: Team 2 Country
type: LABEL
- id: Team 2 Name
type: LABEL
- id: Team 2 Score
type: NUMBER
- id: Stadium Name
type: LABEL
- id: Stadium Location Name
type: LABEL
- id: Attendance
type: NUMBER
- id: Total Goals
type: NUMBER
- id: Match Name
type: LABEL
pages:
- rows:
- columns:
- components:
- html: >-
<p>
<p style="font-size: xx-large">
FIFA World Cup Qatar 2022™
</p>
<small>
Goals Score Statistics
</small>
<hr />
</p>
- properties:
margin-bottom: 100px
margin-top: 50px
columns:
- span: 3
components:
- settings:
type: METRIC
general:
title: Total Goals
columns:
- id: Total Goals
pattern: "#"
lookup:
group:
- functions:
- source: Total Goals
function: SUM
- span: 3
components:
- settings:
type: METRIC
general:
title: Average Goals by Match
lookup:
group:
- functions:
- source: Total Goals
function: AVERAGE
- span: 3
components:
- settings:
type: METRIC
general:
title: Average Temperature
lookup:
group:
- functions:
- source: Temperature
function: AVERAGE
- span: 3
components:
- settings:
type: METRIC
general:
title: Average Attendance
lookup:
group:
- functions:
- source: Attendance
function: AVERAGE
- columns:
- span: 6
components:
- settings:
type: linechart
general:
title: Goals by Day
axis:
x:
labels_angle: 30
lookup:
group:
- columnGroup:
source: Day
functions:
- source: Day
- source: Total Goals
column: Goals
function: ${GoalsFunction}
- span: 6
components:
- settings:
type: barchart
general:
title: Goals by Stadium
axis:
x:
labels_angle: 15
lookup:
sort:
- column: Goals
order: DESCENDING
group:
- columnGroup:
source: Stadium Name
functions:
- source: Stadium Name
- source: Total Goals
function: ${GoalsFunction}
column: Goals
- properties:
margin-top: 20px
columns:
- span: 6
components:
- settings:
type: bubblechart
general:
title: Goals by Weather
subtitle: Bubble shows total matches
lookup:
sort:
- column: TOTAL MATCHES
order: ASCENDING
group:
- columnGroup:
source: Weather
functions:
- source: Weather
- source: Total Goals
function: ${GoalsFunction}
column: Goals
- source: Weather
function: COUNT
column: TOTAL MATCHES
- source: Weather
function: COUNT
column: TOTAL MATCHES
- span: 6
components:
- settings:
type: bubblechart
general:
title: Goals by Attendance
subtitle: Bubble shows total goals
chart:
zoom: true
axis:
x:
labels_show: false
y:
title: Attendance
lookup:
group:
- columnGroup:
source: Match Name
functions:
- source: Match Name
- source: Attendance
column: Attendance
- source: Total Goals
column: Goals
- source: Total Goals
column: Goals
- columns:
- components:
- html: >-
<hr style="width: 2px; border: dashed 1px" />
<p style="margin: 1px 10px 30px 10px; font-size: x-large">
<strong>All Matches</strong>
</p>
- settings:
component: table
external:
width: 100%
height: 500px
columns:
- id: Date
expression: >-
new Date(value).toLocaleDateString() + " " + new Date(value).toLocaleTimeString()
- id: Team 1 Score
pattern: "#"
- id: Team 2 Score
pattern: "#"
lookup:
group:
- functions:
- source: Temperature
- source: ID
- source: Date
- source: Team 1 Score
- source: Match Name
- source: Team 2 Score
- source: Weather
- source: Stadium Name
- source: Attendance
properties:
# use -1 to cancel auto refresh
refreshInterval: -1
# Change to your quarkus installation URL e.g. http://localhost:8080/q/metrics
url: http://localhost:8080/q/metrics
cardTemplate: >-
>-
<div id="${this}" class="card-pf card-pf-aggregate-status" style="background-color: ${bgColor}; width: 90%; height: 80px">
<h2 style="font-weight: 600; font-size: large" id="${this}Value">${value} <span id="${this}Suffix" class=""></span></h2>
<p style="font-weight: 400" id="${this}Title"><em id="${this}Icon" class=""></em> ${title}</p>
</div>
datasets:
- uuid: all_metrics
url: ${url}
columns:
- id: Metric
type: LABEL
- id: Labels
type: LABEL
- id: Value
type: NUMBER
pages:
- properties:
background-color: "#EFEFFF"
rows:
- columns:
- components:
- html: Quarkus Metrics
properties:
font-size: x-large
font-weight: bold
vertical-align: center
padding: 10px
color: "navy"
margin-bottom: 10px
- properties:
margin-right: 10px
columns:
- span: "3"
components:
- settings:
type: METRIC
refresh:
interval: "${refreshInterval}"
general:
visible: "true"
title: "CPU Usage"
html:
html: ${cardTemplate}
javascript: >-
document.getElementById(${this}.id + "Icon").className = "pficon pficon-cpu";
document.getElementById(${this}.id + "Suffix").innerHTML = "%";
columns:
- id: Total
expression: value * 100
lookup:
uuid: all_metrics
filter:
- column: Metric
function: EQUALS_TO
args:
- "system_cpu_usage"
group:
- groupFunctions:
- source: Value
function: MAX
column: Total
- span: "3"
components:
- settings:
type: METRIC
refresh:
interval: "${refreshInterval}"
general:
visible: "true"
title: "Open Files"
html:
html: ${cardTemplate}
javascript: >-
document.getElementById(${this}.id + "Icon").className = "pficon pficon-folder-open";
columns:
- id: Total
pattern: "#"
lookup:
uuid: all_metrics
filter:
- column: Metric
function: EQUALS_TO
args:
- "process_files_open_files"
group:
- groupFunctions:
- source: Value
function: MAX
column: Total
- span: "3"
components:
- settings:
type: METRIC
refresh:
interval: "${refreshInterval}"
general:
visible: "true"
title: "Uptime"
html:
html: ${cardTemplate}
javascript: >-
document.getElementById(${this}.id + "Icon").className = "fa fa-clock-o";
document.getElementById(${this}.id + "Suffix").innerHTML = "min";
columns:
- id: Total
pattern: "#"
expression: value / 60
lookup:
uuid: all_metrics
filter:
- column: Metric
function: EQUALS_TO
args:
- "process_uptime_seconds"
group:
- groupFunctions:
- source: Value
function: MAX
column: Total
- span: "3"
components:
- settings:
type: METRIC
refresh:
interval: "${refreshInterval}"
general:
visible: "true"
title: "Peak Threads"
html:
html: ${cardTemplate}
javascript: document.getElementById(${this}.id + "Icon").className = "fa fa-th";
columns:
- id: Value
pattern: "#"
lookup:
uuid: all_metrics
filter:
- column: Metric
function: EQUALS_TO
args:
- "jvm_threads_peak_threads"
group:
- groupFunctions:
- source: Value
- properties:
margin-top: 20px
columns:
- components:
- settings:
component: echarts
echarts:
color: "#5ec962"
series:
type: bar
title:
text: JVM Memory Used Bytes
refresh:
interval: "${refreshInterval}"
external:
width: 100%
height: 300px
lookup:
uuid: all_metrics
filter:
- column: Metric
function: EQUALS_TO
args:
- "jvm_memory_used_bytes"
sort:
- column: Total
sortOrder: DESCENDING
group:
- columnGroup:
source: Labels
functions:
- source: Labels
- source: Value
function: MAX
column: Total
columns:
- id: Total
pattern: "#"
- properties:
margin-top: 20px
columns:
- components:
- settings:
component: echarts
echarts:
color: "#4695EB"
series:
type: bar
title:
text: Threads
refresh:
interval: "${refreshInterval}"
external:
width: 100%
height: 300px
lookup:
uuid: all_metrics
filter:
- column: Metric
function: EQUALS_TO
args:
- "jvm_threads_states_threads"
sort:
- column: Total
sortOrder: DESCENDING
group:
- columnGroup:
source: Labels
functions:
- source: Labels
- source: Value
function: MAX
column: Total
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17+
// Update the Quarkus version to what you want here or run jbang with
// `-Dquarkus.version=<version>` to override it.
//DEPS io.quarkus:quarkus-bom:${quarkus.version:2.15.0.Final}@pom
//DEPS io.quarkus:quarkus-resteasy
//DEPS io.quarkus:quarkus-micrometer-registry-prometheus
//DEPS org.kie.dashbuilder:dashbuilder-quarkus:0.0.0
//JAVAC_OPTIONS -parameters
//FILES **.dash.yaml
//FILES fifa.dash.yaml
//FILES metrics.dash.yaml
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import io.quarkus.runtime.Quarkus;
@Path("/")
@ApplicationScoped
public class myapp {
@GET
public String sayHello() {
return """
<h1>Hello from Quarkus with jbang.dev and Dashbuilder</h1>
<p>Go to <a href="dashboards">Dashboards</a></p>
""";
}
public static void main(String[] args) {
Quarkus.run(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment