-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PMM-12989 Reduce error logs from diagnostic data on arbiter nodes #820
Changes from 25 commits
14860ab
6a9d825
e7c75b5
4632c93
042a1ab
d65f236
f221e30
de7e193
b89545f
05490bd
67e0886
499d087
eaa6a20
0aa1c35
cf6df50
3ed4e27
f0afc4a
9bad12c
ff005f1
c937ecc
76248ea
9e4c7d5
9358e94
5dd6a44
8826c95
31eacbf
ccd6aa1
6a2fb3b
649a3cc
6f6647a
6ab0b21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ARG TEST_MONGODB_IMAGE=mongo:4.2 | ||
FROM ${TEST_MONGODB_IMAGE} | ||
USER root | ||
COPY docker/secret/keyfile /opt/keyfile | ||
RUN chown mongodb /opt/keyfile && chmod 400 /opt/keyfile && mkdir -p /home/mongodb/ && chown mongodb /home/mongodb | ||
USER mongodb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
P4CWhUl1qj2EiSM+r3mzAHSATiAMBv8l2rAClMrAqOqyyCzVd2tIFW0nOEbSRvoL | ||
Ap7oZkC7IvjX5ELJnqQbxT00+dv1s8U1UFk3J96xro1x3mLgAmASJ1TrFSKXUkss | ||
bbwZ6QBNONCrTNCqlL2q1umLiYUTPeUH0RlLg2GsH1H66a9dEKZaS5AtJIO1hJ6s | ||
znivgdx2vnSA3bs1coR3nEBeNRsMoHp2Dtn9P6FDNlhssZh+EO9GdoRh16cqRiEM | ||
V2VnS2vjEZPpcMrX3ZGU/JBy/bw5GhGXrIfzQrvuKanUsuAVA3bmh6Fh8Rnu66mA | ||
GETO09R/3cjLxHBngZdL9Zn3+3HgDTQHKtpW0ZfjdiK5Xh4JqGXKtDr68S88qgAb | ||
eYQaeJMBoe0o1JXeKYRba+fXmubO7nGN3IDYWulNtkJLe9bx1mseVqlh9FSg7CuG | ||
++sszE7nzmtAlZlaLKlONMm9+dLjhT9n7cSkoWbSIUHvWIzGKC2yadabt7T21VPc | ||
Cyxdaat28xo93J5qjUetjTLKWQmG4eL/AG2/plT7WrTOjQqYCjfFU3XmpVBgtaAr | ||
wkJB8sOUbjcuVJok235Eu/8SxHJKQb0dl8ALwbwLG7CPZMrZ5YF6eJgjE+Sy+WKn | ||
OqfyzNwS7j7nvOvdpRgnHUwwc0G6eIfj90S+XdieJMMuzt7NUS8NsCuQx3nAK0EB | ||
FNWk02pUYE5yHWvmG+7Mo+Jd9OBWcQnGErux6NTYA42uYiMamZgsByBJ2Y8S2a2L | ||
VtbJVhO2indAvGqrGNbdOKGKagFjIQP2A7zsvLFkgfwbBG785CI3Il9jaeQhcefY | ||
Xs0cSSFhFkz/Ak17gU5l0WF6h5HHacWaCzmWdOiZVbOeZboaaxSBry+uZ8oRXPbp | ||
BavuRtu1afTSrikgJdCcoA8Opn7kkETt5xa5PP1dNLEWIMFui2BOlRAw8BDWJ+nD | ||
8fYBaVaqdDs/Y8K0xWHuJjja+s91 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,54 +66,72 @@ func (d *diagnosticDataCollector) collect(ch chan<- prometheus.Metric) { | |
logger := d.base.logger | ||
client := d.base.client | ||
|
||
nodeType, err := getNodeType(d.ctx, client) | ||
if err != nil { | ||
logger.WithFields(logrus.Fields{ | ||
"component": "diagnosticDataCollector", | ||
}).Errorf("Cannot get node type: %s", err) | ||
} | ||
|
||
var metrics []prometheus.Metric | ||
cmd := bson.D{{Key: "getDiagnosticData", Value: "1"}} | ||
res := client.Database("admin").RunCommand(d.ctx, cmd) | ||
if res.Err() != nil { | ||
logger.Errorf("failed to run command: getDiagnosticData: %s", res.Err()) | ||
logger.Warn("cannot run getDiagnosticData, some metrics might be unavailable.") | ||
} | ||
logger.Warnf("failed to run command: getDiagnosticData, some metrics might be unavailable %s", res.Err()) | ||
} else { | ||
if err := res.Decode(&m); err != nil { | ||
logger.Errorf("cannot run getDiagnosticData: %s", err) | ||
return | ||
} | ||
|
||
if err := res.Decode(&m); err != nil { | ||
logger.Errorf("cannot run getDiagnosticData: %s", err) | ||
} | ||
if m == nil || m["data"] == nil { | ||
logger.Error("cannot run getDiagnosticData: response is empty") | ||
} | ||
|
||
if m == nil || m["data"] == nil { | ||
logger.Error("cannot run getDiagnosticData: response is empty") | ||
} | ||
var ok bool | ||
m, ok = m["data"].(bson.M) | ||
if !ok { | ||
err = errors.Wrapf(errUnexpectedDataType, "%T for data field", m["data"]) | ||
logger.Errorf("cannot decode getDiagnosticData: %s", err) | ||
} | ||
|
||
m, ok := m["data"].(bson.M) | ||
if !ok { | ||
err := errors.Wrapf(errUnexpectedDataType, "%T for data field", m["data"]) | ||
logger.Debug("getDiagnosticData result") | ||
debugResult(logger, m) | ||
|
||
logger.Errorf("cannot decode getDiagnosticData: %s", err) | ||
} | ||
metrics = makeMetrics("", m, d.topologyInfo.baseLabels(), d.compatibleMode) | ||
metrics = append(metrics, locksMetrics(logger, m)...) | ||
|
||
logger.Debug("getDiagnosticData result") | ||
debugResult(logger, m) | ||
securityMetric, err := d.getSecurityMetricFromLineOptions(client) | ||
if err != nil { | ||
logger.Errorf("failed to run command: getCmdLineOptions: %s", err) | ||
} else if securityMetric != nil { | ||
metrics = append(metrics, securityMetric) | ||
} | ||
|
||
metrics := makeMetrics("", m, d.topologyInfo.baseLabels(), d.compatibleMode) | ||
metrics = append(metrics, locksMetrics(logger, m)...) | ||
if d.compatibleMode { | ||
metrics = append(metrics, specialMetrics(d.ctx, client, m, nodeType, logger)...) | ||
|
||
securityMetric, err := d.getSecurityMetricFromLineOptions(client) | ||
if err != nil { | ||
logger.Errorf("cannot decode getCmdLineOtpions: %s", err) | ||
} else if securityMetric != nil { | ||
metrics = append(metrics, securityMetric) | ||
if cem, err := cacheEvictedTotalMetric(m); err == nil { | ||
metrics = append(metrics, cem) | ||
} | ||
} | ||
} | ||
|
||
if d.compatibleMode { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at this point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW can we get diagnostic data from mongos? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No actually, the command won't fail, but |
||
metrics = append(metrics, specialMetrics(d.ctx, client, m, logger)...) | ||
buildInfo, err := retrieveMongoDBBuildInfo(d.ctx, client, logger) | ||
if err != nil { | ||
logger.Errorf("cannot retrieve MongoDB buildInfo: %s", err) | ||
} | ||
|
||
if cem, err := cacheEvictedTotalMetric(m); err == nil { | ||
metrics = append(metrics, cem) | ||
metrics = append(metrics, serverVersion(buildInfo)) | ||
|
||
if nodeType == typeArbiter { | ||
if hm := arbiterMetrics(d.ctx, client, logger); hm != nil { | ||
metrics = append(metrics, hm...) | ||
} | ||
} | ||
|
||
nodeType, err := getNodeType(d.ctx, client) | ||
if err != nil { | ||
logger.WithFields(logrus.Fields{ | ||
"component": "diagnosticDataCollector", | ||
}).Errorf("Cannot get node type to check if this is a mongos: %s", err) | ||
} else if nodeType == typeMongos { | ||
if nodeType == typeMongos { | ||
metrics = append(metrics, mongosMetrics(d.ctx, client, logger)...) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍