1.切换到istio根目录

cd /data/istio/istio-0.7.1

2.安装prometheus

kubectl apply -f install/kubernetes/addons/prometheus.yaml

3.创建收集数据的模板

# Configuration for metric instances
apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
name: doublerequestcount
namespace: istio-system
spec:
value: "2" # count each request twice
dimensions:
source: source.service | "unknown"
destination: destination.service | "unknown"
message: '"twice the fun!"'
monitored_resource_type: '"UNSPECIFIED"'
---
# Configuration for a Prometheus handler
apiVersion: "config.istio.io/v1alpha2"
kind: prometheus
metadata:
name: doublehandler
namespace: istio-system
spec:
metrics:
- name: double_request_count # Prometheus metric name
instance_name: doublerequestcount.metric.istio-system # Mixer instance name (fully-qualified)
kind: COUNTER
label_names:
- source
- destination
- message
---
# Rule to send metric instances to a Prometheus handler
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: doubleprom
namespace: istio-system
spec:
actions:
- handler: doublehandler.prometheus
instances:
- doublerequestcount.metric
---
# Configuration for logentry instances
apiVersion: "config.istio.io/v1alpha2"
kind: logentry
metadata:
name: newlog
namespace: istio-system
spec:
severity: '"warning"'
timestamp: request.time
variables:
source: source.labels["app"] | source.service | "unknown"
user: source.user | "unknown"
destination: destination.labels["app"] | destination.service | "unknown"
responseCode: response.code | 0
responseSize: response.size | 0
latency: response.duration | "0ms"
monitored_resource_type: '"UNSPECIFIED"'
---
# Configuration for a stdio handler
apiVersion: "config.istio.io/v1alpha2"
kind: stdio
metadata:
name: newhandler
namespace: istio-system
spec:
severity_levels:
warning: 1 # Params.Level.WARNING
outputAsJson: true
---
# Rule to send logentry instances to a stdio handler
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: newlogstdio
namespace: istio-system
spec:
match: "true" # match for all requests
actions:
- handler: newhandler.stdio
instances:
- newlog.logentry
---
# Configuration for a metric measuring bytes sent from a server
# to a client
apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
name: mongosentbytes
namespace: default
spec:
value: connection.sent.bytes | 0 # uses a TCP-specific attribute
dimensions:
source_service: source.service | "unknown"
source_version: source.labels["version"] | "unknown"
destination_version: destination.labels["version"] | "unknown"
monitoredResourceType: '"UNSPECIFIED"'
---
# Configuration for a metric measuring bytes sent from a client
# to a server
apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
name: mongoreceivedbytes
namespace: default
spec:
value: connection.received.bytes | 0 # uses a TCP-specific attribute
dimensions:
source_service: source.service | "unknown"
source_version: source.labels["version"] | "unknown"
destination_version: destination.labels["version"] | "unknown"
monitoredResourceType: '"UNSPECIFIED"'
---
# Configuration for a Prometheus handler
apiVersion: "config.istio.io/v1alpha2"
kind: prometheus
metadata:
name: mongohandler
namespace: default
spec:
metrics:
- name: mongo_sent_bytes # Prometheus metric name
instance_name: mongosentbytes.metric.default # Mixer instance name (fully-qualified)
kind: COUNTER
label_names:
- source_service
- source_version
- destination_version
- name: mongo_received_bytes # Prometheus metric name
instance_name: mongoreceivedbytes.metric.default # Mixer instance name (fully-qualified)
kind: COUNTER
label_names:
- source_service
- source_version
- destination_version
---
# Rule to send metric instances to a Prometheus handler
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: mongoprom
namespace: default
spec:
match: context.protocol == "tcp"
&& destination.service == "mongodb.default.svc.cluster.local"
actions:
- handler: mongohandler.prometheus
instances:
- mongoreceivedbytes.metric
- mongosentbytes.metric

执行命令:

istioctl create -f new_telemetry.yaml
istioctl create -f tcp_telemetry.yaml

为了测试支持收集tcp metric数据:

kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/kube/bookinfo-ratings-v2.yaml)
kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/kube/bookinfo-db.yaml)
istioctl create -f samples/bookinfo/kube/route-rule-ratings-db.yaml

4.测试

1)访问bookinfo事例

http://192.168.181.99:32693/productpage

2)查看prometheus ui

istio收集Metrics和日志信息的更多相关文章

  1. 【MySQL】关于MySQL错误日志信息的收集

    为方便维护MySQL,写了个脚本用以提供收集错误信息的接口.这些错误信息来自与MySQL错误日志,而 通过grep mysql可以获取error-log的路径. #!/usr/bin/env pyth ...

  2. idou老师教你学Istio :如何用istio实现监控和日志采集

    大家都知道istio可以帮助我们实现灰度发布.流量监控.流量治理等功能.每一个功能都帮助我们在不同场景中实现不同的业务.那Istio是如何帮助我们实现监控和日志采集的呢? 这里我们依然以Bookinf ...

  3. idou老师教你学Istio 25:如何用istio实现监控和日志采集

    大家都知道istio可以帮助我们实现灰度发布.流量监控.流量治理等功能.每一个功能都帮助我们在不同场景中实现不同的业务.那Istio是如何帮助我们实现监控和日志采集的呢? 这里我们依然以Bookinf ...

  4. ASP.NET Core 实战:使用 NLog 将日志信息记录到 MongoDB

    一.前言 在项目开发中,日志系统是系统的一个重要组成模块,通过在程序中记录运行日志.错误日志,可以让我们对于系统的运行情况做到很好的掌控.同时,收集日志不仅仅可以用于诊断排查错误,由于日志同样也是大量 ...

  5. 带你了解zabbix整合ELK收集系统异常日志触发告警~

    今天来了解一下关于ELK的“L”-Logstash,没错,就是这个神奇小组件,我们都知道,它是ELK不可缺少的组件,完成了输入(input),过滤(fileter),output(输出)工作量,也是我 ...

  6. ELK收集Nginx自定义日志格式输出

    1.ELK收集日志的有两种常用的方式: 1.1:不修改源日志格式,简单的说就是在logstash中转通过 grok方式进行过滤处理,将原始无规则的日志转换为规则日志(Logstash自定义日志格式) ...

  7. Flume 概述+环境配置+监听Hive日志信息并写入到hdfs

    Flume介绍Flume是Apache基金会组织的一个提供的高可用的,高可靠的,分布式的海量日志采集.聚合和传输的系统,Flume支持在日志系统中定制各类数据发送方,用于收集数据:同时,Flume提供 ...

  8. svn log — 显示提交日志信息

    http://www.cnblogs.com/eoiioe/archive/2009/01/06/1370580.html 概要svn log [PATH]svn log URL [PATH...]描 ...

  9. Android将日志信息自动发送到指定的邮箱中 邮件的内容以附件形式发送

    今日整合了网上一些大神的例子(具体看了那些大神的?这个真不好意思我忘记了.下次再整合一定给大家补上,这次也只有默默的给那几个大神说声抱歉了.)做了一个“记录android项目中的日志信息,并将日志信息 ...

随机推荐

  1. 挖掘频繁项集之FP-Growth算法

    http://blog.csdn.net/pipisorry/article/details/48918007 FP-Growth频繁项集挖掘算法(Frequent-Pattern Growth, 频 ...

  2. css3动画从入门到精通

    什么是css3动画? 通过 CSS3,我们能够创建动画,这可以在许多网页中取代动画图片.Flash 动画以及 JavaScript. CSS3带来了圆角,半透明,阴影,渐变,多背景图等新的特征,轻松实 ...

  3. org/w3c/dom/ElementTraversal 错误解决办法

    org/w3c/dom/ElementTraversal 错误解决办法 不记得之前几天把什么maven依赖包删除了,今天利用htmlunit运行代码的时候报了下面的错误: Exception in t ...

  4. Java进阶(五十一)必须记住的Myeclipse快捷键

    Java进阶(五十一)必须记住的Myeclipse快捷键 在调试程序的时候,我们经常需要注释一些代码,在用Myeclipse编程时,就可以用 Ctrl+/ 为选中的一段代码加上以 // 打头的注释:当 ...

  5. hadoop学习视频

    杨尚川的视频 http://www.tudou.com/plcover/EvJCo2zl9hQ/ 酷6视频 http://v.ku6.com/show/8PkgqGcarHKndyP3rl_pUw.. ...

  6. (Struts2)XWork容器的实现机理

    模板方法----callInContext 翻开ContainerImpl的实现,我们可以看到callInContext,这个模板方法是容器所有操作调用的基础. 关于模板方法模式,大家可以看出刘伟老师 ...

  7. Media Player Classic - HC 源代码分析 7:详细信息选项卡(CPPageFileInfoDetails)

    ===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...

  8. OpenCV——照亮边缘

    具体的算法原理可以参考: PS滤镜,照亮边缘 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_ ...

  9. EBS R12安装升级(FRESH)(四)

    7 升级Oracle数据库到11gR2 7.1 先打补丁7303030_zhs,9062910,8919489,8919489_ZHS ,9868229,10163753,11071569,97380 ...

  10. objc写一个NSMutableArray不连续索引替换对象的方法

    NSMutableArray内置的方法-(void)replaceObjectsAtIndexes:(NSIndexSet*)set withObjects:(NSArray*)objs 只能替换一段 ...