-
Notifications
You must be signed in to change notification settings - Fork 66
/
wildfly.go
153 lines (133 loc) · 5.79 KB
/
wildfly.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package apps
import (
"context"
"strings"
"github.com/GoogleCloudPlatform/ops-agent/confgenerator"
"github.com/GoogleCloudPlatform/ops-agent/confgenerator/fluentbit"
"github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel"
)
type MetricsReceiverWildfly struct {
confgenerator.ConfigComponent `yaml:",inline"`
confgenerator.MetricsReceiverSharedJVM `yaml:",inline"`
}
const defaultWildflyEndpoint = "service:jmx:remote+http://localhost:9990"
const defaultAdditionalJar = "/opt/wildfly/bin/client/jboss-client.jar"
func (r MetricsReceiverWildfly) Type() string {
return "wildfly"
}
func (r MetricsReceiverWildfly) Pipelines(_ context.Context) ([]otel.ReceiverPipeline, error) {
targetSystem := "wildfly"
if r.MetricsReceiverSharedJVM.Endpoint != "" && !strings.HasPrefix(r.MetricsReceiverSharedJVM.Endpoint, "service:jmx") {
r.MetricsReceiverSharedJVM.Endpoint = "service:jmx:remote+http://" + r.MetricsReceiverSharedJVM.Endpoint
}
return r.MetricsReceiverSharedJVM.
WithDefaultEndpoint(defaultWildflyEndpoint).
WithDefaultAdditionalJars(defaultAdditionalJar).
ConfigurePipelines(
targetSystem,
[]otel.Component{
otel.NormalizeSums(),
otel.MetricsTransform(
otel.AddPrefix("workload.googleapis.com"),
),
otel.ModifyInstrumentationScope(r.Type(), "1.0"),
},
)
}
func init() {
confgenerator.MetricsReceiverTypes.RegisterType(func() confgenerator.MetricsReceiver { return &MetricsReceiverWildfly{} })
}
type LoggingProcessorWildflySystem struct {
confgenerator.ConfigComponent `yaml:",inline"`
}
func (LoggingProcessorWildflySystem) Type() string {
return "wildfly_system"
}
func (p LoggingProcessorWildflySystem) Components(ctx context.Context, tag string, uid string) []fluentbit.Component {
c := confgenerator.LoggingProcessorParseRegex{
// Logging documentation: https://docs.wildfly.org/26/Admin_Guide.html#Logging
// Sample line: 2022-01-18 13:44:35,372 INFO [org.wildfly.security] (ServerService Thread Pool -- 27) ELY00001: WildFly Elytron version 1.18.1.Final
// Sample line: 2022-02-03 15:38:01,509 DEBUG [org.jboss.as.config] (MSC service thread 1-1) VM Arguments: -D[Standalone] -Xms64m -Xmx512m -XX:MetaspaceSize=96M ...Dlogging.configuration=file:/opt/wildfly/standalone/configuration/logging.properties
// Sample line: 2022-02-03 15:38:03,548 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
// Sample line: 2022-02-11 14:29:56,734 INFO [org.jboss.as.process.Server:server-one.status] (ProcessController-threads - 3) WFLYPC0018: Starting process 'Server:server-one'
// Sample line: 2022-02-11 14:29:52,217 INFO [org.jboss.as.process.Host Controller.status] (main) WFLYPC0018: Starting process 'Host Controller'
// Sample line: 2022-02-03 15:38:01,506 DEBUG [org.jboss.as.config] (MSC service thread 1-1) Configured system properties:
// [Standalone] =
// awt.toolkit = sun.awt.X11.XToolkit
// file.encoding = UTF-8
// file.separator = /
Regex: `^(?<time>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3})\s+(?<level>\w+)(?:\s+\[(?<source>.+?)\])?(?:\s+\((?<thread>.+?)\))?\s+(?<message>(?:(?<messageCode>[\d\w]+):)?[\s\S]*)`,
ParserShared: confgenerator.ParserShared{
TimeKey: "time",
TimeFormat: "%Y-%m-%d %H:%M:%S,%L",
},
}.Components(ctx, tag, uid)
c = append(c,
confgenerator.LoggingProcessorModifyFields{
Fields: map[string]*confgenerator.ModifyField{
"severity": {
CopyFrom: "jsonPayload.level",
MapValues: map[string]string{
"TRACE": "TRACE",
"DEBUG": "DEBUG",
"INFO": "INFO",
"ERROR": "ERROR",
"WARN": "WARNING",
},
MapValuesExclusive: true,
},
InstrumentationSourceLabel: instrumentationSourceValue(p.Type()),
},
}.Components(ctx, tag, uid)...,
)
return c
}
type LoggingReceiverWildflySystem struct {
LoggingProcessorWildflySystem `yaml:",inline"`
confgenerator.LoggingReceiverFilesMixin `yaml:",inline" validate:"structonly"`
}
func (r LoggingReceiverWildflySystem) Components(ctx context.Context, tag string) []fluentbit.Component {
if len(r.IncludePaths) == 0 {
r.IncludePaths = []string{
// no package installers, default installation usually provides the following
// Standalone server log
"/opt/wildfly/standalone/log/server.log",
// Managed Domain server log(s)
"/opt/wildfly/domain/servers/*/log/server.log",
// Managed Domain controller log(s)
"/opt/wildfly/domain/log/*.log",
}
}
r.MultilineRules = []confgenerator.MultilineRule{
{
StateName: "start_state",
NextState: "cont",
Regex: `\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}`,
},
{
StateName: "cont",
NextState: "cont",
Regex: `^(?!\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})`,
},
}
c := r.LoggingReceiverFilesMixin.Components(ctx, tag)
c = append(c, r.LoggingProcessorWildflySystem.Components(ctx, tag, "wildfly_system")...)
return c
}
func init() {
confgenerator.LoggingProcessorTypes.RegisterType(func() confgenerator.LoggingProcessor { return &LoggingProcessorWildflySystem{} })
confgenerator.LoggingReceiverTypes.RegisterType(func() confgenerator.LoggingReceiver { return &LoggingReceiverWildflySystem{} })
}