本文介绍了错误 - “无效"不是有效的开始令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 prometheus 控制台中看到目标状态为关闭并且错误无效"不是有效的启动令牌.

我按照以下步骤操作:

  1. 在 linux1 机器上安装 Prometheus.
  2. 在 linux2 机器上安装 weblogic.
  3. 在 weblogic 服务器上部署 jar 文件
  4. 验证仪表
  5. 在 prometheus.yml 中添加 weblogic 服务器条目
  6. 重新启动 prometheus 服务.

以下是详细信息-

普罗米修斯日志:

level=warn ts=2019-09-06T11:42:42.187Z caller=scrape.go:937 component="scrape manager" scrape_pool=weblogic1 target=http://**********.*.****.*:7001/wls-exporter msg="append failed" err="\"INVALID\" is not a valid start token"

curl output1 :--bash-4.2$ curl http://**********.***.****.***:7001/wls-exporter |promtool 检查指标-bash: promtool: 命令未找到% Total % Received % Xferd Average Speed Time Time Time Current下载上传总花费的剩余速度100 1783 100 1783 0 0 323k 0 --:--:-- --:--:-- --:--:-- 348k(23) 写入主体失败-bash-4.2$卷曲输出2:--bash-4.2$ curl -v --noproxy '*' 'http://**********.***.****.***:7001/wls-exporter'* 即将连接()到 ***********.***.****.*** 端口 7001 (#0)*   试 **.**.***.***...* 连接到**********.***.****.*** (**.**.***.***) 端口 7001 (#0)>GET/wls-exporter HTTP/1.1>用户代理:curl/7.29.0>主机:************.***.****.***:7001>接受: */*><HTTP/1.1 200 正常<日期:2019 年 9 月 6 日星期五 11:27:23 GMT<内容长度:1783<<!DOCTYPE html><html lang="zh-cn"><头><meta charset="UTF-8"><title>Weblogic 监控导出器</title><身体><h2>这是 WebLogic 监控导出器.</h2><p>指标位于 <a href="/wls-exporter/metrics">指标相对于这个位置.</p><h2>配置</h2><p>要更改配置:</p><form action="/wls-exporter/configure" method="post" enctype="multipart/form-data"><input type="radio" name="effect" value="append">Append<input type="radio" name="effect" value="replace" checked="checked">Replace<br><input type="file" name="configuration"><br><input type="submit"></表单><p>当前配置</p><p><code><pre>主持人: **********.***.****.***端口:7001查询同步:网址:http://coordinator:8999/刷新间隔:5metricsNameSnakeCase:true域限定符:true休息端口:7001查询:- 键:名称键名:服务器应用程序运行时:关键:姓名键名:应用程序组件运行时:类型:WebAppComponentRuntime前缀:webapp_config_关键:姓名值:[deploymentState、contextRoot、sourceInfo、openSessionsHighCount、openSessionsCurrentCount、sessionsOpenedTotalCount、sessionCookieMaxAgeSecs、sessionInvalidationIntervalSecs、sessionTimeoutSecs、singleThreadedServletPoolSize、sessionIDLength、servletReloadCheckSecs、jSPPageCheckSecs]小服务程序:前缀:weblogic_servlet_键:servletName值:[invocationTotalCount、reloadTotal、executionTimeAverage、poolMaxCapacity、executionTimeTotal、reloadTotalCount、executionTimeHigh、executionTimeLow]- JVM运行时:前缀:jvm_关键:姓名值:[heapFreeCurrent, heapFreePercent, heapSizeCurrent, heapSizeMax, uptime, processCpuLoad]</pre></code></p>* 与主机 ***********.***.****.*** 的连接 #0 保持不变-bash-4.2$

解决方案

错误 ""INVALID" is not a valid start token" 通常在 Prometheus 期望 OpenMetric 格式 但得到别的东西.在这种情况下,如果您在 URL 的 en 中省略 /metrics 或者如果出口商报告错误页面(401 - Authentication required..>

调查 相关源代码,看来Prometheus发送给exporter的认证token是转发给Weblogic API的.prometheus 配置应如下所示:

- job_name: 'weblogic'...基本身份验证:用户名:weblogic密码:朋友

您可以使用带有相关参数的 curl 进行测试:

curl -u 'weblogic:friend' http://**********.***.****.***:7001/wls-exporter/metrics |promtool 检查指标

I can see the target status as down and Error "INVALID" is not a valid start token in prometheus console.

I followed the steps below:

  1. Install Prometheus on linux1 machine.
  2. Install weblogic on linux2 machine.
  3. Deploy jar file on weblogic server
  4. Verify Gauge
  5. Add weblogic server entry in prometheus.yml
  6. Re-start prometheus service.

Below are detailed information -

prometheus logs :

curl output1 :-
-bash-4.2$ curl http://**********.***.****.***:7001/wls-exporter | promtool check metrics
-bash: promtool: command not found
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1783  100  1783    0     0   323k      0 --:--:-- --:--:-- --:--:--  348k
(23) Failed writing body
-bash-4.2$

curl output2 :-
-bash-4.2$ curl -v --noproxy '*' 'http://**********.***.****.***:7001/wls-exporter'
* About to connect() to **********.***.****.*** port 7001 (#0)
*   Trying **.**.***.***...
* Connected to **********.***.****.*** (**.**.***.***) port 7001 (#0)
> GET /wls-exporter HTTP/1.1
> User-Agent: curl/7.29.0
> Host: **********.***.****.***:7001
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 06 Sep 2019 11:27:23 GMT
< Content-Length: 1783
<
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Weblogic Monitoring Exporter</title>
</head>
<body>
<h2>This is the WebLogic Monitoring Exporter.</h2>
<p>The metrics are found at <a href="/wls-exporter/metrics">
metrics</a> relative to this location.
</p>
<h2>Configuration</h2>
<p>To change the configuration:</p>
<form action="/wls-exporter/configure" method="post" enctype="multipart/form-data">
    <input type="radio" name="effect" value="append">Append
    <input type="radio" name="effect" value="replace" checked="checked">Replace
    <br><input type="file" name="configuration">
    <br><input type="submit">
</form>
<p>Current Configuration</p>
<p><code><pre>
host: **********.***.****.***
port: 7001
query_sync:
  url: http://coordinator:8999/
  refreshInterval: 5
metricsNameSnakeCase: true
domainQualifier: true
restPort: 7001
queries:
- key: name
  keyName: server
  applicationRuntimes:
    key: name
    keyName: app
    componentRuntimes:
      type: WebAppComponentRuntime
      prefix: webapp_config_
      key: name
      values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs]
      servlets:
        prefix: weblogic_servlet_
        key: servletName
        values: [invocationTotalCount, reloadTotal, executionTimeAverage, poolMaxCapacity, executionTimeTotal, reloadTotalCount, executionTimeHigh, executionTimeLow]
- JVMRuntime:
    prefix: jvm_
    key: name
    values: [heapFreeCurrent, heapFreePercent, heapSizeCurrent, heapSizeMax, uptime, processCpuLoad]
</pre></code></p>
* Connection #0 to host **********.***.****.*** left intact
-bash-4.2$

解决方案

The error ""INVALID" is not a valid start token" is usually encountered when Prometheus expects an OpenMetric format but get something else. In this occurrence, the exporter landing page if you omit the /metrics at the en of the URL or if the exporter reports an error page (401 - Authentication required.

Looking into the relevant source code, it seems the authentication token sent by Prometheus to the exporter are forwarded to the Weblogic API. The prometheus config should look like:

- job_name: 'weblogic'
  ...
  basic_auth:
    username: weblogic
    password: friend

You can test it using curl with the relevant parameters:

curl -u 'weblogic:friend' http://**********.***.****.***:7001/wls-exporter/metrics | promtool check metrics

这篇关于错误 - “无效"不是有效的开始令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:27