Skip to content

Commit

Permalink
remove grafana-agent helm chart
Browse files Browse the repository at this point in the history
Signed-off-by: Weifeng Wang <qclaogui@gmail.com>

Update alloy-integrations
  • Loading branch information
qclaogui committed Apr 21, 2024
1 parent e0d04c5 commit a626191
Show file tree
Hide file tree
Showing 31 changed files with 2,013 additions and 2,982 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Module Components: component_cluster_events
*/

declare "component_cluster_events" {

/*****************************************************************
* ARGUMENTS
*****************************************************************/
argument "forward_to" {
comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to"
}

argument "job_label" {
optional = true
default = "integrations/kubernetes/eventhandler"
}

argument "cluster" {
optional = true
default = "k3d"
}

loki.source.kubernetes_events "cluster_events" {
job_name = argument.job_label.value
log_format = "logfmt"
forward_to = [loki.process.logs_service.receiver]
}

loki.process "logs_service" {
stage.static_labels {
values = {
cluster = argument.cluster.value,
}
}
forward_to = argument.forward_to.value
}

// // Logs Service
// remote.kubernetes.secret "logs_service" {
// name = "loki-k8s-monitoring"
// namespace = "k8s-monitoring"
// }
// // Loki
// loki.write "logs_service" {
// endpoint {
// url = nonsensitive(remote.kubernetes.secret.logs_service.data["host"]) + "/loki/api/v1/push"
// tenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data["tenantId"])

// basic_auth {
// username = nonsensitive(remote.kubernetes.secret.logs_service.data["username"])
// password = remote.kubernetes.secret.logs_service.data["password"]
// }
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ declare "component_memcached" {
comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to"
}

argument "job_label" {
optional = true
default = "integrations/kubernetes/memcached"
}

argument "memcached_address" {
comment = "address of the Memcached"
optional = true
default = "memcached:11211"
}

argument "memcached_timeout" {
comment = "timeout of the Memcached"
optional = true
default = "5s"
}
Expand Down Expand Up @@ -62,7 +65,7 @@ declare "component_memcached" {

rule {
target_label = "job"
replacement = "integrations/kubernetes/memcached"
replacement = argument.job_label.value
}

rule {
Expand Down
113 changes: 113 additions & 0 deletions kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
Module Components: component_mysql
*/

declare "component_mysql" {

/*****************************************************************
* ARGUMENTS
*****************************************************************/
argument "forward_to" {
comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to"
}

argument "job_label" {
optional = true
default = "integrations/kubernetes/mysql"
}

argument "namespace" {
optional = true
default = "monitoring-system"
}

argument "name" {
optional = true
default = "alloy-integrations-mysql"
}

argument "instance_name" {
optional = true
}

argument "keep_metrics" {
optional = true
default = "(up|instance:mysql_heartbeat_lag_seconds|instance:mysql_slave_lag_seconds|mysql_global_status_aborted_clients|mysql_global_status_aborted_connects|mysql_global_status_buffer_pool_pages|mysql_global_status_bytes_received|mysql_global_status_bytes_sent|mysql_global_status_commands_total|mysql_global_status_created_tmp_disk_tables|mysql_global_status_created_tmp_files|mysql_global_status_created_tmp_tables|mysql_global_status_handlers_total|mysql_global_status_innodb_log_waits|mysql_global_status_innodb_mem_adaptive_hash|mysql_global_status_innodb_mem_dictionary|mysql_global_status_innodb_num_open_files|mysql_global_status_innodb_page_size|mysql_global_status_max_used_connections|mysql_global_status_open_files|mysql_global_status_open_table_definitions|mysql_global_status_open_tables|mysql_global_status_opened_files|mysql_global_status_opened_table_definitions|mysql_global_status_opened_tables|mysql_global_status_qcache_free_memory|mysql_global_status_qcache_hits|mysql_global_status_qcache_inserts|mysql_global_status_qcache_lowmem_prunes|mysql_global_status_qcache_not_cached|mysql_global_status_qcache_queries_in_cache|mysql_global_status_queries|mysql_global_status_questions|mysql_global_status_select_full_join|mysql_global_status_select_full_range_join|mysql_global_status_select_range|mysql_global_status_select_range_check|mysql_global_status_select_scan|mysql_global_status_slow_queries|mysql_global_status_sort_merge_passes|mysql_global_status_sort_range|mysql_global_status_sort_rows|mysql_global_status_sort_scan|mysql_global_status_table_locks_immediate|mysql_global_status_table_locks_waited|mysql_global_status_table_open_cache_hits|mysql_global_status_table_open_cache_misses|mysql_global_status_table_open_cache_overflows|mysql_global_status_threads_cached|mysql_global_status_threads_connected|mysql_global_status_threads_created|mysql_global_status_threads_running|mysql_global_status_uptime|mysql_global_status_wsrep_local_recv_queue|mysql_global_status_wsrep_local_state|mysql_global_status_wsrep_ready|mysql_global_variables_innodb_additional_mem_pool_size|mysql_global_variables_innodb_buffer_pool_size|mysql_global_variables_innodb_log_buffer_size|mysql_global_variables_key_buffer_size|mysql_global_variables_max_connections|mysql_global_variables_open_files_limit|mysql_global_variables_query_cache_size|mysql_global_variables_table_definition_cache|mysql_global_variables_table_open_cache|mysql_global_variables_thread_cache_size|mysql_global_variables_tokudb_cache_size|mysql_global_variables_wsrep_desync|mysql_heartbeat_now_timestamp_seconds|mysql_heartbeat_stored_timestamp_seconds|mysql_info_schema_processlist_threads|mysql_slave_status_seconds_behind_master|mysql_slave_status_slave_io_running|mysql_slave_status_slave_sql_running|mysql_slave_status_sql_delay|mysql_up)"
}

argument "scrape_interval" {
comment = "How often to scrape metrics from the targets (default: 60s)"
optional = true
default = "60s"
}

argument "scrape_timeout" {
comment = "How long before a scrape times out (default: 10s)"
optional = true
default = "10s"
}

remote.kubernetes.secret "mysql" {
name = argument.name.value
namespace = argument.namespace.value
}

/***************************************************************
* Integrations Mysql
****************************************************************/
prometheus.exporter.mysql "integrations_mysqld_exporter" {
data_source_name = nonsensitive(remote.kubernetes.secret.mysql.data["mysql-username"]) + ":" + nonsensitive(remote.kubernetes.secret.mysql.data["mysql-password"]) + "@(" + nonsensitive(remote.kubernetes.secret.mysql.data["mysql-host"]) + ")/"
}

/***************************************************************
* Discovery Relabelings (pre-scrape)
****************************************************************/
discovery.relabel "integrations_mysqld_exporter" {
targets = prometheus.exporter.mysql.integrations_mysqld_exporter.targets

rule {
target_label = "job"
replacement = argument.job_label.value
}

rule {
target_label = "instance"
replacement = coalesce(argument.instance_name.value, constants.hostname)
}
}

/***************************************************************
* Prometheus Scrape Integrations Targets
****************************************************************/
prometheus.scrape "integrations_mysqld_exporter" {
targets = concat(
discovery.relabel.integrations_mysqld_exporter.output,
)

enable_protobuf_negotiation = true
scrape_classic_histograms = true

scrape_interval = argument.scrape_interval.value
scrape_timeout = argument.scrape_timeout.value

clustering {
enabled = true
}

forward_to = [prometheus.relabel.integrations_mysqld_exporter.receiver]
}

/***************************************************************
* Prometheus Metric Relabelings (post-scrape)
****************************************************************/
prometheus.relabel "integrations_mysqld_exporter" {
forward_to = argument.forward_to.value

// keep only metrics that match the keep_metrics regex
rule {
source_labels = ["__name__"]
regex = argument.keep_metrics.value
action = "keep"
}
}
}
114 changes: 114 additions & 0 deletions kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
Module Components: component_redis_exporter
*/

declare "component_redis_exporter" {

/*****************************************************************
* ARGUMENTS
*****************************************************************/
argument "forward_to" {
comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to"
}

argument "job_label" {
optional = true
default = "integrations/kubernetes/redis_exporter"
}

argument "namespace" {
optional = true
default = "monitoring-system"
}

argument "name" {
optional = true
default = "alloy-integrations-redis"
}

argument "instance_name" {
optional = true
}

argument "keep_metrics" {
optional = true
default = "(up|redis_blocked_clients|redis_cluster_slots_fail|redis_cluster_slots_pfail|redis_cluster_state|redis_commands_duration_seconds_total|redis_commands_total|redis_connected_clients|redis_connected_slaves|redis_db_keys|redis_db_keys_expiring|redis_evicted_keys_total|redis_keyspace_hits_total|redis_keyspace_misses_total|redis_master_last_io_seconds_ago|redis_memory_fragmentation_ratio|redis_memory_max_bytes|redis_memory_used_bytes|redis_memory_used_rss_bytes|redis_total_system_memory_bytes|redis_up)"
}

argument "scrape_interval" {
comment = "How often to scrape metrics from the targets (default: 60s)"
optional = true
default = "60s"
}

argument "scrape_timeout" {
comment = "How long before a scrape times out (default: 10s)"
optional = true
default = "10s"
}

remote.kubernetes.secret "redis" {
name = argument.name.value
namespace = argument.namespace.value
}

/***************************************************************
* Integrations Redis
****************************************************************/
prometheus.exporter.redis "integrations_redis_exporter" {
redis_addr = nonsensitive(remote.kubernetes.secret.redis.data["redis-addr"])
redis_password = nonsensitive(remote.kubernetes.secret.redis.data["redis-password"])
}

/***************************************************************
* Discovery Relabelings (pre-scrape)
****************************************************************/
discovery.relabel "integrations_redis_exporter" {
targets = prometheus.exporter.memcached.integrations_redis_exporter.targets

rule {
target_label = "job"
replacement = argument.job_label.value
}

rule {
target_label = "instance"
replacement = coalesce(argument.instance_name.value, constants.hostname)
}
}

/***************************************************************
* Prometheus Scrape Integrations Targets
****************************************************************/
prometheus.scrape "integrations_redis_exporter" {
targets = concat(
discovery.relabel.integrations_redis_exporter.output,
)

enable_protobuf_negotiation = true
scrape_classic_histograms = true

scrape_interval = argument.scrape_interval.value
scrape_timeout = argument.scrape_timeout.value

clustering {
enabled = true
}

forward_to = [prometheus.relabel.integrations_redis_exporter.receiver]
}

/***************************************************************
* Prometheus Metric Relabelings (post-scrape)
****************************************************************/
prometheus.relabel "integrations_redis_exporter" {
forward_to = argument.forward_to.value

// keep only metrics that match the keep_metrics regex
rule {
source_labels = ["__name__"]
regex = argument.keep_metrics.value
action = "keep"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,39 @@ declare "integrations_scrape" {
/*****************************************************************
* Import Integrations Components
*****************************************************************/
// integrate components local files
import.file "integrate" {
// integrations components local files
import.file "integrations" {
filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/integrations"
}

// // integrate components kubernetes configmap
// // integrations components kubernetes configmap
// remote.kubernetes.configmap "integrations" {
// name = argument.name.value
// namespace = argument.namespace.value
// }
// import.string "integrate" {
// import.string "integrations" {
// content = remote.kubernetes.configmap.integrations.data["memcached.alloy"]
// }

/*****************************************************************
* Memcached Integrations
*****************************************************************/
integrate.component_memcached "primary" {
integrations.component_memcached "primary" {
forward_to = argument.forward_to.value

instance_name = "primary"
memcached_address = "memcached.memcached-system.svc.cluster.local:11211"
memcached_timeout = "5s"
}

// /*****************************************************************
// * Mysql Integrations
// *****************************************************************/
// integrations.component_mysql "primary" {
// forward_to = argument.forward_to.value

// instance_name = "primary"
// name = "alloy-integrations-mysql"
// namespace = "monitoring-system"
// }
}
Loading

0 comments on commit a626191

Please sign in to comment.