write code in python to get logs from cloudwatch but only from eks export to json file.
Here is an example of Python code that retrieves logs from CloudWatch, filters them to only include logs from an EKS cluster, and exports them to a JSON file:
```
import boto3
import json

# Set up CloudWatch Logs client
logs = boto3.client('logs')

# Set up filter to only include logs from EKS cluster
filter_pattern = 'eks-cluster-name'

# Set up parameters for GetLogEvents API call
params = {
    'logGroupName': '/aws/eks/eks-cluster-name/cluster',
   'startTime': 1,  # 1 second ago
    'endTime': int(datetime.datetime.now().timestamp()),
    'filterPattern': filter_pattern,
    'limit': 1000  # retrieve up to 1000 log events
}

# Call GetLogEvents API
response = logs.get_log_events(**params)

# Extract log events from response
log_events = response['events']

# Create a list to store log events in JSON format
log_events_json = []

# Iterate over log events and convert to JSON
for event in log_events:
    log_event_json = {
        'timestamp': event['timestamp'],
       'message': event['message'],
        'ingestionTime': event['ingestionTime']
    }
    log_events_json.append(log_event_json)

# Write log events to JSON file
with open('eks_logs.json', 'w') as f:
    json.dump(log_events_json, f,
 Sure, here's an example Python code that uses the Boto3 library to get logs from CloudWatch for an EKS cluster and exports them to a JSON file:
```python
import boto3
import json

# Replace these variables with your own values
aws_access_key_id = 'YOUR_AWS_ACCESS_KEY_ID'
aws_secret_access_key = 'YOUR_AWS_SECRET_ACCESS_KEY'
region_name = 'YOUR_REGION_NAME'
eks_cluster_name = 'YOUR_EKS_CLUSTER_NAME'
log_group_name = '/aws/eks/' + eks_cluster_name + '/cluster'
log_stream_prefix = eks_cluster_name + '-'
start_time = int((datetime.now() - timedelta(days=7)).timestamp()) # Get logs from the last 7 days

# Create a CloudWatch client
client = boto3.client('logs', aws_access_key_id=aws_access_key_id,
                      aws_secret_access_key=aws_secret_access_key, region_name=region_name)

# Get a list of log streams for the log group
response = client.describe_log_streams(log