Skip to content

Commit c74eab8

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 72ca6e8 commit c74eab8

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

observability/install-observability.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,36 @@ echo -e "\n${YELLOW}Waiting for all pods to be ready...${NC}"
199199
kubectl wait --for=condition=ready pod --all -n observability --timeout=300s
200200
echo -e "${GREEN}✓ All pods are ready${NC}"
201201

202+
# Import Grafana dashboards
203+
echo -e "\n${YELLOW}Importing Grafana dashboards...${NC}"
204+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
205+
206+
if [ -f "$SCRIPT_DIR/jvm-metrics-dashboard.json" ]; then
207+
kubectl create configmap jvm-metrics-dashboard \
208+
--from-file="$SCRIPT_DIR/jvm-metrics-dashboard.json" \
209+
-n observability \
210+
--dry-run=client -o yaml | \
211+
kubectl label --dry-run=client --local -f - grafana_dashboard=1 -o yaml | \
212+
kubectl apply -f -
213+
echo -e "${GREEN}✓ JVM Metrics dashboard imported${NC}"
214+
else
215+
echo -e "${YELLOW}⚠ JVM Metrics dashboard not found at $SCRIPT_DIR/jvm-metrics-dashboard.json${NC}"
216+
fi
217+
218+
if [ -f "$SCRIPT_DIR/josdk-operator-metrics-dashboard.json" ]; then
219+
kubectl create configmap josdk-operator-metrics-dashboard \
220+
--from-file="$SCRIPT_DIR/josdk-operator-metrics-dashboard.json" \
221+
-n observability \
222+
--dry-run=client -o yaml | \
223+
kubectl label --dry-run=client --local -f - grafana_dashboard=1 -o yaml | \
224+
kubectl apply -f -
225+
echo -e "${GREEN}✓ JOSDK Operator Metrics dashboard imported${NC}"
226+
else
227+
echo -e "${YELLOW}⚠ JOSDK Operator Metrics dashboard not found at $SCRIPT_DIR/josdk-operator-metrics-dashboard.json${NC}"
228+
fi
229+
230+
echo -e "${GREEN}✓ Dashboards will be available in Grafana shortly${NC}"
231+
202232
# Get pod statuses
203233
echo -e "\n${GREEN}========================================${NC}"
204234
echo -e "${GREEN}Installation Complete!${NC}"
@@ -237,16 +267,17 @@ echo -e " ${GREEN}OTEL_TRACES_EXPORTER=otlp${NC}"
237267
echo -e "\n${GREEN}========================================${NC}"
238268
echo -e "${GREEN}Grafana Dashboards${NC}"
239269
echo -e "${GREEN}========================================${NC}"
240-
echo -e "\nPre-installed dashboards in Grafana:"
270+
echo -e "\nAutomatically imported dashboards:"
271+
echo -e " - ${GREEN}JOSDK - JVM Metrics${NC} - Java Virtual Machine health and performance"
272+
echo -e " - ${GREEN}JOSDK - Operator Metrics${NC} - Kubernetes operator performance and reconciliation"
273+
echo -e "\nPre-installed Kubernetes dashboards:"
241274
echo -e " - Kubernetes / Compute Resources / Cluster"
242275
echo -e " - Kubernetes / Compute Resources / Namespace (Pods)"
243276
echo -e " - Node Exporter / Nodes"
244-
echo -e "\nFor JOSDK metrics, create a custom dashboard with queries like:"
245-
echo -e " ${GREEN}sum(rate(operator_sdk_reconciliations_started_total[5m]))${NC}"
246-
echo -e " ${GREEN}sum(rate(operator_sdk_reconciliations_success_total[5m]))${NC}"
247-
echo -e " ${GREEN}sum(rate(operator_sdk_reconciliations_failed_total[5m]))${NC}"
277+
echo -e "\n${YELLOW}Note:${NC} Dashboards may take 30-60 seconds to appear in Grafana after installation."
248278

249279
echo -e "\n${YELLOW}To uninstall:${NC}"
280+
echo -e " kubectl delete configmap -n observability jvm-metrics-dashboard josdk-operator-metrics-dashboard"
250281
echo -e " kubectl delete -n observability OpenTelemetryCollector otel-collector"
251282
echo -e " helm uninstall -n observability kube-prometheus-stack"
252283
echo -e " helm uninstall -n observability opentelemetry-operator"

sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageOperator.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
import io.javaoperatorsdk.operator.sample.probes.StartupHandler;
3434
import io.micrometer.core.instrument.Clock;
3535
import io.micrometer.core.instrument.MeterRegistry;
36+
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
37+
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
38+
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
39+
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
40+
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
41+
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
3642
import io.micrometer.registry.otlp.OtlpConfig;
3743
import io.micrometer.registry.otlp.OtlpMeterRegistry;
3844

@@ -78,7 +84,20 @@ public static void main(String[] args) throws IOException {
7884
OtlpConfig otlpConfig = configProperties::get;
7985

8086
MeterRegistry registry = new OtlpMeterRegistry(otlpConfig, Clock.SYSTEM);
81-
return MicrometerMetrics.withoutPerResourceMetrics(registry);
87+
88+
// Register JVM and system metrics
89+
log.info("Registering JVM and system metrics...");
90+
new JvmMemoryMetrics().bindTo(registry);
91+
new JvmGcMetrics().bindTo(registry);
92+
new JvmThreadMetrics().bindTo(registry);
93+
new ClassLoaderMetrics().bindTo(registry);
94+
new ProcessorMetrics().bindTo(registry);
95+
new UptimeMetrics().bindTo(registry);
96+
log.info("JVM and system metrics registered");
97+
98+
return MicrometerMetrics.newPerResourceCollectingMicrometerMetricsBuilder(registry)
99+
.collectingMetricsPerResource()
100+
.build();
82101
}
83102

84103
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)