Kiali is not working with VictoriaMetricsHello - istio

Was anyone was able to make kiali visualise mesh using VictoriaMetrics instead of Prometheus?
When I use prometheus and kiali setup from istio samples then Mesh Visualisation works.
But when I replace prometheus with Victoria Metrics (agent, select, insert, storage) then kiali simply showing empty graph.
I have checked that both Prometheus and Victoria Metrics have the same istio_requests_total metric.
But when I use Victoria Metrics select URL in spec.external_services.prometheus.url the graph comes empty.
apiVersion: kiali.io/v1alpha1
kind: Kiali
metadata:
name: kiali
namespace: istio-system
spec:
auth:
strategy: anonymous
external_services:
istio:
config_map_name: istio-1-14
url_service_version: http://istiod-1-14:15014/version
prometheus:
url: http://vmselect-example-vmcluster-persistent.poc.svc.cluster.local:8481/select/0/prometheus/
In logs I see two errors related to the fact that vm-select does not have corresponding endpoints
2022-07-15T19:25:13Z ERR Failed to fetch Prometheus configuration: bad_response: readObjectStart: expect { or n, but found r, error found in #1 byte of ...|remoteAddr:|..., bigger context ...|remoteAddr: "10.4.34.83:57468"; requestURI: /select|...
2022-07-15T19:25:13Z ERR Failed to fetch Prometheus flags: bad_response: readObjectStart: expect { or n, but found r, error found in #1 byte of ...|remoteAddr:|..., bigger context ...|remoteAddr: "10.4.34.83:57468"; requestURI: /select|...
and multiple warnings
2022-07-15T19:35:28Z WRN Skipping {destination_canonical_revision="v1", destination_canonical_service="microservice", destination_cluster="Kubernetes", destination_service="microservice.poc.svc.cluster.local", destination_service_name="microservice", destination_service_namespace="poc", destination_workload="microservice", destination_workload_namespace="poc", request_protocol="http", response_code="200", response_flags="-", source_canonical_revision="latest", source_canonical_service="istio-ingressgateway-internal", source_cluster="Kubernetes"}, missing expected TS labels
Here is my VMPodScrape which I expect will take all metrics from all pods
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMPodScrape
metadata:
name: all-scrape
namespace: poc
spec:
podMetricsEndpoints:
- scheme: http
path: /stats/prometheus
targetPort: 15090
selector: {}
namespaceSelector:
any: true

Error messages don't look critical, in case of error kiali should use default values. As far as I understand, it tries to recognize scrape interval and retention based on prometheus configuration file and flags.
I think you have an issue with relabeling config, it drops labels required for kiali.
There is docs with needed labels by metric name:
https://kiali.io/docs/faq/general/#which-istio-metrics-and-attributes-are-required-by-kiali
I'd recommend check scrape config at VMAgent. Probably relabeling rules are outdated.

Related

XFF header in kong ingress

I've recently started to work with kong, on my ngnix ingress I had XFF header set as follows:
annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/configuration-snippet: | more_set_headers "X-Forwarded-For $http_x_forwarded_for";
I am now trying to add the XFF header to the kong ingress however it seems like the kong.config file isn't available for me (some internal reasons I'm trying to figure) but adding it manually for the ing should also do the trick if I understand correctly.
I found that the below config can be added:
name: ingress namespace: default config: functions: - ngx.var.upstream_x_forwarded_for=xxxxx plugin: serverless-functions
However it seems something is off with my syntax, would appreciate any input on the matter

Unable to create working subscription for Event Hub topic in Dapr

I have a Dapr application running locally, self-hosted with the Dapr cli. I've configured a Dapr Component and Subscription for subscribing to an Azure Event Hub, detailed below:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: eventhubs-pubsub
spec:
type: pubsub.azure.eventhubs
version: v1
metadata:
- name: connectionString
value: "Endpoint=sb://[removed].servicebus.windows.net/;SharedAccessKeyName=[removed];SharedAccessKey=[removed];EntityPath=myhub"
- name: enableEntityManagement
value: "false"
- name: storageAccountName
value: "[removed]"
- name: storageAccountKey
value: "[removed]"
- name: storageContainerName
value: "myapp"
scopes:
- myapp
apiVersion: dapr.io/v1alpha1
kind: Subscription
metadata:
name: myhub-subscription
spec:
topic: myhub
route: /EventHubsInput
pubsubname: eventhubs-pubsub
scopes:
- myapp
I've manually created a consumer group with the name of the Dapr app id - "myapp".
I've called the HTTP endpoint directly - a POST verb returning 200 - and it works fine. It also responds to OPTIONS verb.
The application starts succsesfully with no errors or warnings. I can see a logged message saying:
INFO[0000] connectionString provided is specific to event hub "myhub". Publishing or subscribing to a topic that does not match this event hub will fail when attempted. app_id=myapp instance=OldManWaterfall scope=dapr.contrib type=log ver=1.6.0
INFO[0000] component loaded. name: eventhubs-pubsub, type: pubsub.azure.eventhubs/v1 app_id=myapp instance=OldManWaterfall scope=dapr.runtime type=log ver=1.6.0
No other message is logged regarding the pubsub and no message indicating a failure or success of the subscription itself. Nothing is created in the storgae container. If I remove the storage related config from the Component no failure is reported, despite those properties being mandatory. When I put a message on the Hub, unsurprisingly nothing happens.
What am I doing wrong? Everything I've read seems to indicate this set up should work.
I was able to fix this by exposing my app over http instead of https. Unfortunately there was no logging to indicate https was the issue, even with debug level switched on.

istio setting request size limits - lookup failed: 'request.size'

I am attempting to limit traffic by request size using istio. Given that the virtual service does not provide this I am trying to due it via a mixer policy.
I setup the following
---
apiVersion: "config.istio.io/v1alpha2"
kind: handler
metadata:
name: denylargerequest
spec:
compiledAdapter: denier
params:
status:
code: 9
message: Request Too Large
---
apiVersion: "config.istio.io/v1alpha2"
kind: instance
metadata:
name: denylargerequest
spec:
compiledTemplate: checknothing
---
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: denylargerequest
spec:
match: destination.labels["app"] == "httpbin" && request.size > 100
actions:
- handler: denylargerequest
instances: [ denylargerequest ]
Requests are not denied and I see the following error from istio-mixer
2020-01-07T15:42:40.564240Z warn input set condition evaluation error: id='2', error='lookup failed: 'request.size''
If I remove the request.size portion of the match I get the expected behavior which is a 400 http status with a message about request size. Of course, I get it on every request which is not desired. But that, along with the above error makes it clear that the request.size attribute is the problem.
I do not see anywhere in istio's docs what attributes are available to the mixer rules.
I am running istio 1.3.0.
Any suggestions on the mixer rule? Or an alternative way to enforce request size limits via istio?
The rule match mentioned in the question:
match: destination.labels["app"] == "httpbin" && request.size > 100
will not work because of mismatched attribute types.
According to istio documentation:
Match is an attribute based predicate. When Mixer receives a request
it evaluates the match expression and executes all the associated
actions if the match evaluates to true.
A few example match:
an empty match evaluates to true
true, a boolean literal; a rule with this match will always be executed
match(destination.service.host, "ratings.*") selects any request targeting a service whose name starts with “ratings”
attr1 == "20" && attr2 == "30" logical AND, OR, and NOT are also available
This means that the request.size > 100 has integer values that are not supported.
However, it is possible to do with help of Common Expression Language (CEL).
You can enable CEL in istio by using the policy.istio.io/lang annotation (set it to CEL).
Then by using Type Values from the List of Standard Definitions we can use functions to parse values into different types.
Just as a suggesion for solution.
Alternative way would be to use envoyfilter filter like in this github issue.
According to another related github issue about Envoy's per connection buffer limit:
The current resolution is to use envoyfilter, reopen if you feel this is a must feature
Hope this helps.

How can I confirm whether Circuit Breaking (via DestinationRule) is at work or not for external service (ServiceEntry & VirtualService)

Summary of Problem
I'm trying to impose Circuit Breaker parameters for an external endpoint outside of my mesh, hosted somewhere else. However, the parameters I have set doesn't seem to be imposed because I am still getting successful HTTP 200 responses, when I expect it to start failing with HTTP 503.
Tools versions are:
Istio-1.2.4
Kubernetes: v1.10.11
Docker Dekstop Version 2.0.0.3
Notable config:
global.outboundTrafficPolicy.mode is REGISTRY_ONLY.
Within Mesh is mTLS. External traffic policy, TLS is DISABLED
Related Resources
ServiceEntry
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: external-service
spec:
hosts:
- external-service.sample.com
location: MESH_EXTERNAL
exportTo:
- "*"
ports:
- number: 80
name: http
protocol: HTTP
resolution: DNS
VirtualService
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: external-service-vs
spec:
hosts:
- external-service.sample.com
http:
- timeout: 200ms
retries:
attempts: 1
perTryTimeout: 200ms
route:
- destination:
host: external-service.sample.com
port:
number: 80
DestinationRule
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: external-service-dr
spec:
host: external-service.sample.com
trafficPolicy:
tls:
mode: DISABLE
connectionPool:
tcp:
maxConnections: 1
connectTimeout: 200ms
http:
http2MaxRequests: 1
http1MaxPendingRequests: 1
maxRequestsPerConnection: 1
maxRetries: 1
idleTimeout: 200ms
outlierDetection:
consecutiveErrors: 1
interval: 1s
baseEjectionTime: 10s
maxEjectionPercent: 100
Testing
I have an application inside the mesh injected with an Envoy Proxy. The app basically just run load concurrent for HTTP1.1 GET external-service.sample.com/endpoint.
I adjust the number of concurrent users in the App (1 to 10) and requests per second per user (1 to 20).
I was expecting for the response to start failing with the ramp up. But that's not the case. I get success throughout.
Key Asks
If you see something very glaring, please point it out.
I already checked logs and /stats from my Envoy Proxy (outgoing request and response). What other istio logs do I need to check to understand more whether the request was subjected and evaluated by istio to the destinationrule or not?
Besides the statistic data gathered by Istio Mixer from nested Envoy instances, you might consider fetching Circuit Breaker events from Envoy Access logs.
Since Access logging enabled across Istio mesh plane, you can extract the relevant Circuit Breaker log entries, distinguished by specific response flags:
UO: Upstream overflow (circuit breaking) in addition to 503 response
code.
And fetched up record from container's envoy proxy access logs, i.e:
[2019-09-18T09:49:56.716Z] "GET /headers HTTP/1.1" 503 UO "-" "-" 0 81 0 - "-"
I have not really addressed the issue directly on this.
But, I have done the whole setup from the start with a clean slate all over again from setting up istio. And after that it was already throwing the expected HTTP 503.
It was rather challenging than necessary to know the state of the circuit breakers. There was supposed to be a ticket logged, but it seems development for such feature is not yet on the horizon.
Nevertheless, when verifying, I did take a look on some telemetry metrics to understand the circuit breaker state. I think this way could be better because I only want to know whether the circuit is close or open at a moment and not analyze from multiple input data.
Thanks.

How to enable user-level rate limiting in istio

I saw Istio site mention Rate Limiting support but I can only find global rate-limit example.
Is it possible to do so at user-level? For example, if my user logged in but sends more than 50 requests within a second then I'd like to block said user, etc. In a similar situation, if user doesn't logged in then that device cannot send more than 30 requests per seconds.
Yes it is possible to conditionally apply rate limits based on arbitrary
attributes using a match condition in the quota rule.
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
name: quota
namespace: istio-system
spec:
match: source.namespace != destination.namespace
actions:
- handler: handler.memquota
instances:
- requestcount.quota
The quota will only apply when the source namespace is not equal to the destination namespace. In your case you probablty want to set a match like this:
match:
request:
headers:
cookie:
regex: "^(.*?;)?(user=jason)(;.*)?$"
I made a PR to improve the rate-limiting docs you can find it here: https://github.com/istio/istio.github.io/pull/1109